VCCC  2024.05
VisualCamp Common C++ library
is_swappable_cxx14.hpp
Go to the documentation of this file.
1 //
2 // Created by yonggyulee on 2023/12/20.
3 //
4 
5 #ifndef VCCC_TYPE_TRAITS_DETAIL_IS_SWAPPABLE_CXX14_HPP_
6 #define VCCC_TYPE_TRAITS_DETAIL_IS_SWAPPABLE_CXX14_HPP_
7 
8 #include <array>
9 #include <deque>
10 #include <forward_list>
11 #include <list>
12 #include <map>
13 #include <memory>
14 #include <set>
15 #include <stack>
16 #include <string>
17 #include <queue>
18 #include <tuple>
19 #include <type_traits>
20 #include <unordered_map>
21 #include <unordered_set>
22 #include <utility>
23 #include <vector>
24 
27 
28 namespace vccc {
29 namespace internal {
30 
32 
33 template<typename T1, typename T2>
34 struct is_swappable_with_impl<std::pair<T1, T2>&, std::pair<T1, T2>&>
35  : conjunction<is_swappable<T1>, is_swappable<T2>> {
36  static constexpr bool nothrow = is_nothrow_swappable<T1>::value && is_nothrow_swappable<T2>::value;
37 };
38 
39 template<typename T1, typename T2>
40 struct is_swappable_with_impl<const std::pair<T1, T2>&, const std::pair<T1, T2>&>
41  : conjunction<is_swappable<const T1>, is_swappable<const T2>> {
43 };
44 
45 
47 
48 template<typename... Types>
49 struct is_swappable_with_impl<std::tuple<Types...>&, std::tuple<Types...>&>
50  : conjunction<is_swappable<Types>...> {
51  static constexpr bool nothrow = conjunction<is_nothrow_swappable<Types>...>::value;
52 };
53 
54 template<typename... Types>
55 struct is_swappable_with_impl<const std::tuple<Types...>&, const std::tuple<Types...>&>
56  : conjunction<is_swappable<const Types>...> {
57  static constexpr bool nothrow = conjunction<is_nothrow_swappable<const Types>...>::value;
58 };
59 
60 
62 
63 template<typename T, typename D>
64 struct is_swappable_with_impl<std::unique_ptr<T, D>&, std::unique_ptr<T, D>&> : is_swappable<D> {
65  static constexpr bool nothrow = true;
66 };
67 
68 
70 
71 template<typename CharT, typename Traits, typename Allocator>
72 struct is_swappable_with_impl<std::basic_string<CharT, Traits, Allocator>&, std::basic_string<CharT, Traits, Allocator>&> : std::true_type {
73  static constexpr bool nothrow =
76 };
77 
79 
80 template<typename T>
81 struct is_swappable_with_impl<std::array<T, 0>&, std::array<T, 0>&> : std::true_type {
82  static constexpr bool nothrow = true;
83 };
84 
85 template<typename T, std::size_t N>
86 struct is_swappable_with_impl<std::array<T, N>&, std::array<T, N>&> : is_swappable<T> {
87  static constexpr bool nothrow = is_nothrow_swappable<T>::value;
88 };
89 
90 
92 
93 template<typename T, typename Alloc>
94 struct is_swappable_with_impl<std::deque<T, Alloc>&, std::deque<T, Alloc>&> : std::true_type {
95  static constexpr bool nothrow = std::allocator_traits<Alloc>::is_always_equal::value;
96 };
97 
98 
100 
101 template<typename T, typename Alloc>
102 struct is_swappable_with_impl<std::forward_list<T, Alloc>&, std::forward_list<T, Alloc>&> : std::true_type {
103  static constexpr bool nothrow = std::allocator_traits<Alloc>::is_always_equal::value;
104 };
105 
106 
108 
109 template<typename T, typename Alloc>
110 struct is_swappable_with_impl<std::list<T, Alloc>&, std::list<T, Alloc>&> : std::true_type {
111  static constexpr bool nothrow = std::allocator_traits<Alloc>::is_always_equal::value;
112 };
113 
114 
116 
117 template<typename T, typename Alloc>
118 struct is_swappable_with_impl<std::vector<T, Alloc>&, std::vector<T, Alloc>&> : std::true_type {
119  static constexpr bool nothrow =
122 };
123 
124 
126 
127 template<typename Key, typename T, typename Compare, typename Alloc>
128 struct is_swappable_with_impl<std::map<Key, T, Compare, Alloc>&, std::map<Key, T, Compare, Alloc>&> : std::true_type {
129  static constexpr bool nothrow =
132 };
133 
134 
136 
137 template<typename Key, typename T, typename Compare, typename Alloc>
138 struct is_swappable_with_impl<std::multimap<Key, T, Compare, Alloc>&, std::multimap<Key, T, Compare, Alloc>&> : std::true_type {
139  static constexpr bool nothrow =
142 };
143 
144 
146 
147 template<typename Key, typename Compare, typename Alloc>
148 struct is_swappable_with_impl<std::set<Key, Compare, Alloc>&, std::set<Key, Compare, Alloc>&> : std::true_type {
149  static constexpr bool nothrow =
152 };
153 
154 
156 
157 template<typename Key, typename Compare, typename Alloc>
158 struct is_swappable_with_impl<std::multiset<Key, Compare, Alloc>&, std::multiset<Key, Compare, Alloc>&> : std::true_type {
159  static constexpr bool nothrow =
162 };
163 
164 
166 
167 template<typename Key, typename T, typename Hash, typename KeyEqual, typename Alloc>
168 struct is_swappable_with_impl<std::unordered_map<Key, T, Hash, KeyEqual, Alloc>&, std::unordered_map<Key, T, Hash, KeyEqual, Alloc>&> : std::true_type {
169  static constexpr bool nothrow =
173 };
174 
175 
177 
178 template<typename Key, typename T, typename Hash, typename KeyEqual, typename Alloc>
179 struct is_swappable_with_impl<std::unordered_multimap<Key, T, Hash, KeyEqual, Alloc>&, std::unordered_multimap<Key, T, Hash, KeyEqual, Alloc>&> : std::true_type {
180  static constexpr bool nothrow =
184 };
185 
186 
188 
189 template<typename Key, typename Hash, typename KeyEqual, typename Alloc>
190 struct is_swappable_with_impl<std::unordered_set<Key, Hash, KeyEqual, Alloc>&, std::unordered_set<Key, Hash, KeyEqual, Alloc>&> : std::true_type {
191  static constexpr bool nothrow =
195 };
196 
197 
199 
200 template<typename Key, typename Hash, typename KeyEqual, typename Alloc>
201 struct is_swappable_with_impl<std::unordered_multiset<Key, Hash, KeyEqual, Alloc>&, std::unordered_multiset<Key, Hash, KeyEqual, Alloc>&> : std::true_type {
202  static constexpr bool nothrow =
206 };
207 
208 
210 
211 template<typename T, typename Container>
212 struct is_swappable_with_impl<std::queue<T, Container>&, std::queue<T, Container>&> : is_swappable<Container> {
213  static constexpr bool nothrow = is_nothrow_swappable<Container>::value;
214 };
215 
216 
218 
219 template<typename T, typename Container, typename Compare>
220 struct is_swappable_with_impl<std::priority_queue<T, Container, Compare>&, std::priority_queue<T, Container, Compare>&>
221  : conjunction<is_swappable<Container>, is_swappable<Compare>> {
222  static constexpr bool nothrow = conjunction<is_nothrow_swappable<Container>, is_nothrow_swappable<Compare>>::value;
223 };
224 
225 
227 
228 template<typename T, typename Container>
229 struct is_swappable_with_impl<std::stack<T, Container>&, std::stack<T, Container>&> : is_swappable<Container> {
230  static constexpr bool nothrow = is_nothrow_swappable<Container>::value;
231 };
232 
233 }
234 } // namespace vccc
235 
236 #endif // VCCC_TYPE_TRAITS_DETAIL_IS_SWAPPABLE_CXX14_HPP_
Definition: matrix.hpp:495
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35