VCCC  2024.05
VisualCamp Common C++ library
assignable_from.hpp
Go to the documentation of this file.
1 //
2 // Created by cosge on 2023-12-02.
3 //
4 
5 #ifndef VCCC_CONCEPTS_ASSIGNABLE_FROM_HPP_
6 #define VCCC_CONCEPTS_ASSIGNABLE_FROM_HPP_
7 
8 #include <type_traits>
9 
14 
15 #ifdef _MSC_VER
16 #pragma warning( push )
17 #pragma warning( disable : 4244)
18 #endif
19 
20 namespace vccc {
21 namespace impl {
22 
23 template<
24  typename LHS, typename RHS,
27  : same_as<decltype( std::declval<LHS>() = std::declval<RHS>() ), LHS> {};
28 
29 template<typename LHS, typename RHS>
30 struct assignable_from_requires<LHS, RHS, false> : std::false_type {};
31 
32 
33 template<typename LHS, typename RHS>
35  : conjunction<
36  common_reference_with<
37  const std::remove_reference_t<LHS>&,
38  const std::remove_reference_t<RHS>&>,
39  assignable_from_requires<LHS, RHS>
40  > {};
41 } // namespace impl
42 
45 
46 
57 template<typename LHS, typename RHS>
59  : std::conditional_t<
60  conjunction<
61  std::is_lvalue_reference<LHS>,
62  is_referencable< std::remove_reference_t<LHS> >,
63  is_referencable< std::remove_reference_t<RHS> > >::value,
64  impl::assignable_from_impl<LHS, RHS>,
65  std::false_type
66  > {};
67 
70 
71 } // namespace vccc
72 
73 #ifdef _MSC_VER
74 #pragma warning( pop )
75 #endif
76 
77 #endif // VCCC_CONCEPTS_ASSIGNABLE_FROM_HPP_
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35
Models std::assignable_from
Definition: assignable_from.hpp:66
Definition: conjunction.hpp:22
Definition: assignable_from.hpp:40
Definition: assignable_from.hpp:27
Models std::same_as
Definition: same_as.hpp:33