Phi
is_swappable_with.hpp
1 #ifndef INCG_PHI_CORE_TYPE_TRAITS_IS_SWAPPABLE_WITH_HPP
2 #define INCG_PHI_CORE_TYPE_TRAITS_IS_SWAPPABLE_WITH_HPP
3 
4 #include "phi/phi_config.hpp"
5 
6 #if PHI_HAS_EXTENSION_PRAGMA_ONCE()
7 # pragma once
8 #endif
9 
10 #include "phi/algorithm/swap.hpp"
11 #include "phi/compiler_support/constexpr.hpp"
12 #include "phi/compiler_support/inline_variables.hpp"
13 #include "phi/core/declval.hpp"
14 #include "phi/type_traits/integral_constant.hpp"
15 #include "phi/type_traits/void_t.hpp"
16 
17 DETAIL_PHI_BEGIN_NAMESPACE()
18 
19 namespace detail
20 {
21  using phi::swap;
22 
23  template <typename TypeT, typename OtherT, typename = void>
25  {};
26 
27  template <typename TypeT, typename OtherT>
29  TypeT, OtherT, void_t<decltype(swap(phi::declval<TypeT>(), phi::declval<OtherT>()))>>
30  : public true_type
31  {};
32 
33  template <typename TypeT, typename OtherT>
35  : public integral_constant<bool, is_swappable_with_helper<TypeT, OtherT>::value &&
36  is_swappable_with_helper<OtherT, TypeT>::value>
37  {};
38 } // namespace detail
39 
40 template <typename TypeT, typename OtherT>
42  : public integral_constant<bool, detail::is_swappable_with_impl<TypeT, OtherT>::value>
43 {};
44 
45 template <typename TypeT, typename OtherT>
47  : public integral_constant<bool, !is_swappable_with<TypeT, OtherT>::value>
48 {};
49 
50 #if PHI_HAS_FEATURE_VARIABLE_TEMPLATE()
51 
52 template <typename TypeT, typename OtherT>
53 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_swappable_with_v =
55 
56 template <typename TypeT, typename OtherT>
57 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_not_swappable_with_v =
59 
60 #endif
61 
62 DETAIL_PHI_END_NAMESPACE()
63 
64 #endif // INCG_PHI_CORE_TYPE_TRAITS_IS_SWAPPABLE_WITH_HPP
Definition: integral_constant.hpp:19
Definition: is_swappable_with.hpp:46
Definition: swap.hpp:23
Definition: is_swappable_with.hpp:41
Definition: common_type.test.cpp:195
Definition: is_swappable_with.hpp:24
Definition: is_swappable_with.hpp:34