1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2015-2015.
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // See http://www.boost.org/libs/move for documentation.
10 //////////////////////////////////////////////////////////////////////////////
14 #ifndef BOOST_MOVE_DETAIL_META_UTILS_CORE_HPP
15 #define BOOST_MOVE_DETAIL_META_UTILS_CORE_HPP
17 #ifndef BOOST_CONFIG_HPP
18 # include <boost/config.hpp>
21 #if defined(BOOST_HAS_PRAGMA_ONCE)
25 //Small meta-typetraits to support move
28 namespace move_detail {
31 struct voider { typedef void type; };
33 //////////////////////////////////////
35 //////////////////////////////////////
36 template<bool C, typename T1, typename T2>
42 template<typename T1, typename T2>
43 struct if_c<false,T1,T2>
48 //////////////////////////////////////
50 //////////////////////////////////////
51 template<typename T1, typename T2, typename T3>
52 struct if_ : if_c<0 != T1::value, T2, T3>
55 //////////////////////////////////////
57 //////////////////////////////////////
58 struct enable_if_nat{};
60 template <bool B, class T = enable_if_nat>
67 struct enable_if_c<false, T> {};
69 //////////////////////////////////////
71 //////////////////////////////////////
72 template <class Cond, class T = enable_if_nat>
73 struct enable_if : enable_if_c<Cond::value, T> {};
75 //////////////////////////////////////
77 //////////////////////////////////////
78 template <bool B, class T = enable_if_nat>
83 //////////////////////////////////////
85 //////////////////////////////////////
86 template <class Cond, class T = enable_if_nat>
87 struct disable_if : enable_if_c<!Cond::value, T> {};
89 //////////////////////////////////////
91 //////////////////////////////////////
92 template<class T, T v>
93 struct integral_constant
95 static const T value = v;
97 typedef integral_constant<T, v> type;
99 operator T() const { return value; }
100 T operator()() const { return value; }
103 typedef integral_constant<bool, true > true_type;
104 typedef integral_constant<bool, false > false_type;
107 //////////////////////////////////////
109 //////////////////////////////////////
110 template<class T, class U>
113 static const bool value = false;
119 static const bool value = true;
122 //////////////////////////////////////
124 //////////////////////////////////////
125 template <class T, class U, class R = enable_if_nat>
126 struct enable_if_same : enable_if<is_same<T, U>, R> {};
128 //////////////////////////////////////
130 //////////////////////////////////////
131 template <class T, class U, class R = enable_if_nat>
132 struct disable_if_same : disable_if<is_same<T, U>, R> {};
134 } //namespace move_detail {
135 } //namespace boost {
137 #endif //#ifndef BOOST_MOVE_DETAIL_META_UTILS_CORE_HPP