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_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#include <__type_traits/is_same.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class...>
25using __expand_to_true _LIBCPP_NODEBUG = true_type;
26
27template <class... _Pred>
28__expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
29
30template <class...>
31false_type __and_helper(...);
32
33// _And always performs lazy evaluation of its arguments.
34//
35// However, `_And<_Pred...>` itself will evaluate its result immediately (without having to
36// be instantiated) since it is an alias, unlike `conjunction<_Pred...>`, which is a struct.
37// If you want to defer the evaluation of `_And<_Pred...>` itself, use `_Lazy<_And, _Pred...>`.
38template <class... _Pred>
39using _And _LIBCPP_NODEBUG = decltype(std::__and_helper<_Pred...>(0));
40
41template <bool... _Preds>
42struct __all_dummy;
43
44template <bool... _Pred>
45struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...> > {};
46
47#if _LIBCPP_STD_VER >= 17
48
49template <class...>
50struct _LIBCPP_NO_SPECIALIZATIONS conjunction : true_type {};
51
52_LIBCPP_DIAGNOSTIC_PUSH
53# if __has_warning("-Winvalid-specialization")
54_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
55# endif
56template <class _Arg>
57struct conjunction<_Arg> : _Arg {};
58
59template <class _Arg, class... _Args>
60struct conjunction<_Arg, _Args...> : conditional_t<!bool(_Arg::value), _Arg, conjunction<_Args...>> {};
61_LIBCPP_DIAGNOSTIC_POP
62
63template <class... _Args>
64_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool conjunction_v = conjunction<_Args...>::value;
65
66#endif // _LIBCPP_STD_VER >= 17
67
68_LIBCPP_END_NAMESPACE_STD
69
70#endif // _LIBCPP___TYPE_TRAITS_CONJUNCTION_H
71

Warning: This file is not a C or C++ file. It does not have highlighting.

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