VCCC  2024.05
VisualCamp Common C++ library
boolean_testable.hpp
Go to the documentation of this file.
1 //
2 // Created by yonggyulee on 2023/12/25.
3 //
4 
5 #ifndef VCCC_CONCEPTS_BOOLEAN_TESTABLE_HPP_
6 #define VCCC_CONCEPTS_BOOLEAN_TESTABLE_HPP_
7 
8 #include <type_traits>
9 
13 
14 namespace vccc {
15 namespace detail {
16 
17 template<typename B>
18 struct boolean_testable_impl : convertible_to<B, bool> {};
19 
20 template<typename T, typename = void>
21 struct is_explicitly_negatable : std::false_type {};
22 template<typename T>
23 struct is_explicitly_negatable<T, void_t<decltype(!std::declval<T>())> > : std::true_type {};
24 
25 template<
26  typename B,
27  bool =
28  conjunction<
29  is_explicitly_negatable<std::add_lvalue_reference_t<std::remove_reference_t<B>>>,
30  is_explicitly_negatable<std::add_rvalue_reference_t<std::remove_reference_t<B>>>
31  >::value
32 >
33 struct boolean_testable_stage_2 : std::false_type {};
34 
35 template<typename B>
36 struct boolean_testable_stage_2<B, true>
37  : conjunction<
38  boolean_testable_impl<decltype(!std::declval< std::add_lvalue_reference_t<std::remove_reference_t<B>> >())>,
39  boolean_testable_impl<decltype(!std::declval< std::add_rvalue_reference_t<std::remove_reference_t<B>> >())>
40  > {};
41 
42 template<
43  typename B,
44  bool = conjunction<boolean_testable_impl<B>, is_referencable<B>>::value
45 >
46 struct boolean_testable_stage_1 : std::false_type {};
47 
48 template<typename B>
49 struct boolean_testable_stage_1<B, true> : boolean_testable_stage_2<B> {};
50 
51 } // namespace detail
52 
58 
68 template<typename B>
69 struct boolean_testable : detail::boolean_testable_stage_1<B> {};
70 
73 
74 } // namespace vccc
75 
76 #endif // VCCC_CONCEPTS_BOOLEAN_TESTABLE_HPP_
void void_t
Definition: void_t.hpp:19
Definition: matrix.hpp:495
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35
Definition: boolean_testable.hpp:69