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_CONDITIONAL_H |
10 | #define _LIBCPP___TYPE_TRAITS_CONDITIONAL_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 <bool> |
21 | struct _IfImpl; |
22 | |
23 | template <> |
24 | struct _IfImpl<true> { |
25 | template <class _IfRes, class _ElseRes> |
26 | using _Select _LIBCPP_NODEBUG = _IfRes; |
27 | }; |
28 | |
29 | template <> |
30 | struct _IfImpl<false> { |
31 | template <class _IfRes, class _ElseRes> |
32 | using _Select _LIBCPP_NODEBUG = _ElseRes; |
33 | }; |
34 | |
35 | template <bool _Cond, class _IfRes, class _ElseRes> |
36 | using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>; |
37 | |
38 | template <bool _Bp, class _If, class _Then> |
39 | struct _LIBCPP_NO_SPECIALIZATIONS conditional { |
40 | using type _LIBCPP_NODEBUG = _If; |
41 | }; |
42 | |
43 | _LIBCPP_DIAGNOSTIC_PUSH |
44 | #if __has_warning("-Winvalid-specialization") |
45 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") |
46 | #endif |
47 | template <class _If, class _Then> |
48 | struct conditional<false, _If, _Then> { |
49 | using type _LIBCPP_NODEBUG = _Then; |
50 | }; |
51 | _LIBCPP_DIAGNOSTIC_POP |
52 | |
53 | #if _LIBCPP_STD_VER >= 14 |
54 | template <bool _Bp, class _IfRes, class _ElseRes> |
55 | using conditional_t _LIBCPP_NODEBUG = typename conditional<_Bp, _IfRes, _ElseRes>::type; |
56 | #endif |
57 | |
58 | // Helper so we can use "conditional_t" in all language versions. |
59 | template <bool _Bp, class _If, class _Then> |
60 | using __conditional_t _LIBCPP_NODEBUG = typename conditional<_Bp, _If, _Then>::type; |
61 | |
62 | _LIBCPP_END_NAMESPACE_STD |
63 | |
64 | #endif // _LIBCPP___TYPE_TRAITS_CONDITIONAL_H |
65 |
Warning: This file is not a C or C++ file. It does not have highlighting.