Support Class Library
A set of tools providing classes and utility
swap.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef SCL_CPP17
4  #include <type_traits>
5  #include <utility>
7  #include <scl/tools/meta/exists.h>
8  #include <scl/tools/meta/is_same.h>
10 
11  #define SCL_t std::declval<T&>()
12  #define SCL_u std::declval<U&>()
13 
14  namespace scl{
15  namespace tools{
16  namespace meta{
17  namespace details{
18  template <class T, class U, class = void>
19  struct __is_swappable_with : std::false_type{};
20 
21  template <class T, class U>
23  exists<decltype(std::swap(SCL_t, SCL_u))>()
24  && exists<decltype(std::swap(SCL_u, SCL_t))>()
25  >>> : std::true_type{};
26 
27  template <class T, class U>
28  constexpr bool is_swappable_with(){
30  }
31 
32  template <class T, class = void>
33  struct __is_swappable : std::false_type{};
34 
35  template <class T>
38  && is_swappable_with<T&, T&>()
39  >> : std::true_type{};
40  }
41 
42  template <class T>
43  constexpr bool is_swappable(){
45  }
46  }
47  }
48  }
49 
50  #undef SCL_t
51  #undef SCL_u
52 #endif
void void_t
The must have.
Definition: void_t.h:10
Global namespace of the SCL.
Definition: alias.hpp:3
STL namespace.
constexpr bool is_same()
An handy function for the result of std::is_same.
Definition: is_same.h:12
typename std::add_lvalue_reference< T >::type add_lvalue_reference_t
Definition: type_mod.h:21
constexpr bool exists()
Determines whether or not the given type is well-formed.
Definition: exists.h:23
constexpr bool is_swappable()
Definition: swap.h:43
constexpr bool is_swappable_with()
Definition: swap.h:28
typename std::enable_if< B, T >::type enable_if_t
An handy type alias for the result of std::enable_if.
Definition: enable_if.h:12