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
20template <bool>
21struct _IfImpl;
22
23template <>
24struct _IfImpl<true> {
25 template <class _IfRes, class _ElseRes>
26 using _Select _LIBCPP_NODEBUG = _IfRes;
27};
28
29template <>
30struct _IfImpl<false> {
31 template <class _IfRes, class _ElseRes>
32 using _Select _LIBCPP_NODEBUG = _ElseRes;
33};
34
35template <bool _Cond, class _IfRes, class _ElseRes>
36using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>;
37
38template <bool _Bp, class _If, class _Then>
39struct _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
47template <class _If, class _Then>
48struct conditional<false, _If, _Then> {
49 using type _LIBCPP_NODEBUG = _Then;
50};
51_LIBCPP_DIAGNOSTIC_POP
52
53#if _LIBCPP_STD_VER >= 14
54template <bool _Bp, class _IfRes, class _ElseRes>
55using 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.
59template <bool _Bp, class _If, class _Then>
60using __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.

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