VCCC  2024.05
VisualCamp Common C++ library
common_with.hpp
Go to the documentation of this file.
1 //
2 // Created by cosge on 2023-12-02.
3 //
4 
5 #ifndef VCCC_CONCEPTS_COMMON_WITH_HPP_
6 #define VCCC_CONCEPTS_COMMON_WITH_HPP_
7 
8 #include <type_traits>
9 
16 
17 namespace vccc {
18 namespace detail {
19 
20 template<
21  typename T,
22  typename U,
23  bool = conjunction<
24  same_as< common_type_t<T, U>, common_type_t<U, T> >,
25  has_typename_type<
26  common_reference<std::add_lvalue_reference_t<const T>,
27  std::add_lvalue_reference_t<const U>> >
28  >::value /* false */
29 >
30 struct common_with_impl_2 : std::false_type {};
31 
32 template<typename T, typename U>
33 struct common_with_impl_2<T, U, true>
34  : conjunction<
35  std::is_constructible< common_type_t<T, U>, decltype(std::declval<T>()) >,
36  std::is_constructible< common_type_t<T, U>, decltype(std::declval<U>()) >,
37  common_reference_with<
38  std::add_lvalue_reference_t<const T>,
39  std::add_lvalue_reference_t<const U>>,
40  common_reference_with<
41  std::add_lvalue_reference_t<common_type_t<T, U>>,
42  common_reference_t<
43  std::add_lvalue_reference_t<const T>,
44  std::add_lvalue_reference_t<const U>
45  >
46  >
47  > {};
48 
49 
50 template<
51  typename T,
52  typename U,
53  bool = conjunction<has_typename_type< common_type<T, U> >,
54  has_typename_type< common_type<U, T> >
55  >::value /* true */
56 >
57 struct common_with_impl_1 : common_with_impl_2<T, U> {};
58 
59 template<typename T, typename U>
60 struct common_with_impl_1<T, U, false> : std::false_type {};
61 
62 } // namespace detail
63 
66 
78 template<typename T, typename U>
79 struct common_with : detail::common_with_impl_1<T, U> {};
80 
82 
83 } // namespace vccc
84 
85 #endif // VCCC_CONCEPTS_COMMON_REFERENCE_WITH_HPP_
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35
specifies that two types share a common type
Definition: common_with.hpp:79