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_TEMPLATE_VIS conditional {typedef _If type;};
40 template <class _If, class _Then>
41     struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
42 
43 #if _LIBCPP_STD_VER > 11
44 template <bool _Bp, class _IfRes, class _ElseRes>
45 using conditional_t = typename conditional<_Bp, _IfRes, _ElseRes>::type;
46 #endif
47 
48 // Helper so we can use "conditional_t" in all language versions.
49 template <bool _Bp, class _If, class _Then> using __conditional_t = typename conditional<_Bp, _If, _Then>::type;
50 
51 _LIBCPP_END_NAMESPACE_STD
52 
53 #endif // _LIBCPP___TYPE_TRAITS_CONDITIONAL_H
54