VCCC  2024.05
VisualCamp Common C++ library
swappable_with.hpp
Go to the documentation of this file.
1 //
2 // Created by cosge on 2023-12-03.
3 //
4 
5 #ifndef VCCC_CONCEPTS_SWAPPABLE_WITH_HPP_
6 #define VCCC_CONCEPTS_SWAPPABLE_WITH_HPP_
7 
8 #include <type_traits>
9 
11 #include "vccc/__concepts/swap.hpp"
14 
15 namespace vccc {
16 namespace detail {
17 
18 template<typename T, typename U, typename = void>
19 struct swap_uref_test : std::false_type {};
20 
21 template<typename T, typename U>
22 struct swap_uref_test<T, U, void_t<decltype( ranges::swap(std::declval<T>(), std::declval<U>()) )>> : std::true_type {};
23 
24 
26 struct swappable_with_impl : std::false_type {};
27 
28 template<typename T, typename U>
29 struct swappable_with_impl<T, U, true>
30  : conjunction<
31  swap_uref_test<T, T>,
32  swap_uref_test<U, U>,
33  swap_uref_test<T, U>,
34  swap_uref_test<U, T>
35  > {};
36 
37 } // namespace detail
38 
41 
50 template<typename T, typename U>
51 struct swappable_with : detail::swappable_with_impl<T, U> {};
52 
54 
55 } // namespace vccc
56 
57 #endif // VCCC_CONCEPTS_SWAPPABLE_WITH_HPP_
void void_t
Definition: void_t.hpp:19
constexpr std::enable_if_t< conjunction< is_swappable< T >, is_swappable< U > >::value > swap(compressed_pair< T, U > &lhs, compressed_pair< T, U > &rhs) noexcept(conjunction< is_nothrow_swappable< T >, is_nothrow_swappable< U >>::value)
Definition: compressed_pair.hpp:108
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35
specifies that a type can be swapped or that two types can be swapped with each other
Definition: swappable_with.hpp:51