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_INTEGRAL_CONSTANT_H |
10 | #define _LIBCPP___TYPE_TRAITS_INTEGRAL_CONSTANT_H |
11 | |
12 | #include <__config> |
13 | |
14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
15 | # pragma GCC system_header |
16 | #endif |
17 | |
18 | _LIBCPP_BEGIN_NAMESPACE_STD |
19 | |
20 | template <class _Tp, _Tp __v> |
21 | struct _LIBCPP_TEMPLATE_VIS integral_constant |
22 | { |
23 | static _LIBCPP_CONSTEXPR const _Tp value = __v; |
24 | typedef _Tp value_type; |
25 | typedef integral_constant type; |
26 | _LIBCPP_INLINE_VISIBILITY |
27 | _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;} |
28 | #if _LIBCPP_STD_VER > 11 |
29 | _LIBCPP_INLINE_VISIBILITY |
30 | constexpr value_type operator ()() const _NOEXCEPT {return value;} |
31 | #endif |
32 | }; |
33 | |
34 | template <class _Tp, _Tp __v> |
35 | _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; |
36 | |
37 | typedef integral_constant<bool, true> true_type; |
38 | typedef integral_constant<bool, false> false_type; |
39 | |
40 | template <bool _Val> |
41 | using _BoolConstant _LIBCPP_NODEBUG = integral_constant<bool, _Val>; |
42 | |
43 | #if _LIBCPP_STD_VER > 14 |
44 | template <bool __b> |
45 | using bool_constant = integral_constant<bool, __b>; |
46 | #endif |
47 | |
48 | _LIBCPP_END_NAMESPACE_STD |
49 | |
50 | #endif // _LIBCPP___TYPE_TRAITS_INTEGRAL_CONSTANT_H |
51 |