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_CONJUNCTION_H |
10 | #define _LIBCPP___TYPE_TRAITS_CONJUNCTION_H |
11 | |
12 | #include <__config> |
13 | #include <__type_traits/conditional.h> |
14 | #include <__type_traits/enable_if.h> |
15 | #include <__type_traits/integral_constant.h> |
16 | |
17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
18 | # pragma GCC system_header |
19 | #endif |
20 | |
21 | _LIBCPP_BEGIN_NAMESPACE_STD |
22 | |
23 | #if _LIBCPP_STD_VER > 14 |
24 | |
25 | template <class _Arg, class... _Args> |
26 | struct __conjunction_impl { |
27 | using type = conditional_t<!bool(_Arg::value), _Arg, typename __conjunction_impl<_Args...>::type>; |
28 | }; |
29 | |
30 | template <class _Arg> |
31 | struct __conjunction_impl<_Arg> { |
32 | using type = _Arg; |
33 | }; |
34 | |
35 | template <class... _Args> |
36 | struct conjunction : __conjunction_impl<true_type, _Args...>::type {}; |
37 | |
38 | template<class... _Args> |
39 | inline constexpr bool conjunction_v = conjunction<_Args...>::value; |
40 | |
41 | #endif // _LIBCPP_STD_VER > 14 |
42 | |
43 | template <class...> |
44 | using __expand_to_true = true_type; |
45 | |
46 | template <class... _Pred> |
47 | __expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int); |
48 | |
49 | template <class...> |
50 | false_type __and_helper(...); |
51 | |
52 | template <class... _Pred> |
53 | using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0)); |
54 | |
55 | _LIBCPP_END_NAMESPACE_STD |
56 | |
57 | #endif // _LIBCPP___TYPE_TRAITS_CONJUNCTION_H |
58 | |