Warning: This file is not a C or C++ file. It does not have highlighting.

1//===----------------------------------------------------------------------===//
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 _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H
10#define _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__type_traits/aligned_storage.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <size_t _I0, size_t... _In>
23struct __static_max;
24
25template <size_t _I0>
26struct __static_max<_I0> {
27 static const size_t value = _I0;
28};
29
30template <size_t _I0, size_t _I1, size_t... _In>
31struct __static_max<_I0, _I1, _In...> {
32 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : __static_max<_I1, _In...>::value;
33};
34
35template <size_t _Len, class _Type0, class... _Types>
36struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_NO_SPECIALIZATIONS aligned_union {
37 static const size_t alignment_value =
38 __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
39 static const size_t __len = __static_max<_Len, sizeof(_Type0), sizeof(_Types)...>::value;
40 typedef typename aligned_storage<__len, alignment_value>::type type;
41};
42
43#if _LIBCPP_STD_VER >= 14
44template <size_t _Len, class... _Types>
45using aligned_union_t _LIBCPP_DEPRECATED_IN_CXX23 = typename aligned_union<_Len, _Types...>::type;
46#endif
47
48_LIBCPP_END_NAMESPACE_STD
49
50#endif // _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H
51

Warning: This file is not a C or C++ file. It does not have highlighting.

source code of libcxx/include/__type_traits/aligned_union.h