xref: /llvm-project/libc/src/__support/CPP/type_traits/aligned_storage.h (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
1 //===-- aligned_storage type_traits    --------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALIGNED_STORAGE_H
10 #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALIGNED_STORAGE_H
11 
12 #include "src/__support/macros/config.h"
13 #include <stddef.h> // size_t
14 
15 namespace LIBC_NAMESPACE_DECL {
16 namespace cpp {
17 
18 template <size_t Len, size_t Align> struct aligned_storage {
19   struct type {
20     alignas(Align) unsigned char data[Len];
21   };
22 };
23 
24 template <size_t Len, size_t Align>
25 using aligned_storage_t = typename aligned_storage<Len, Align>::type;
26 
27 } // namespace cpp
28 } // namespace LIBC_NAMESPACE_DECL
29 
30 #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALIGNED_STORAGE_H
31