25 #if __cplusplus >= 201103L
28 template <
typename T>
struct has_move_constructor
33 struct AmbiguousConverter
38 template <
typename C>
static no& test(decltype(
new C( AmbiguousConverter{} )));
39 template <
typename>
static yes& test(...);
40 enum { value = (
sizeof(test<T>(0)) ==
sizeof(yes)) };
44 #if __cplusplus >= 201103L || _MSC_VER >= 1600
46 using std::conditional;
48 using std::false_type;
49 using std::integral_constant;
50 using std::is_base_of;
51 using std::is_integral;
53 using std::reference_wrapper;
54 using std::remove_const;
56 using std::remove_volatile;
58 using std::make_unsigned;
59 using std::make_signed;
62 # define GS_BIND1ST(_op,_arg) std::bind(_op, _arg, std::placeholders::_1)
63 # define GS_BIND2ND(_op,_arg) std::bind(_op, std::placeholders::_1, _arg)
67 # define GS_BIND1ST(_op,_arg) std::bind1st(_op,_arg)
68 # define GS_BIND2ND(_op,_arg) std::bind2nd(_op,_arg)
72 template<
bool B,
class T,
class F>
struct conditional {
typedef T type; };
73 template<
class T,
class F>
struct conditional<false, T, F> {
typedef F type; };
75 template<
bool B,
class T =
void>
struct enable_if {};
76 template<
class T>
struct enable_if<true, T> {
typedef T type;};
78 template<
class T,
class U>
struct is_same {
enum { value = 0 }; };
79 template<
class T>
struct is_same<T, T> {
enum { value = 1 }; };
81 template<
typename U>
struct is_pointer {
static const bool value =
false; };
82 template<
typename U>
struct is_pointer<U*> {
static const bool value = true ; };
84 template <
typename B,
typename D>
struct Host
85 {
operator B*()
const;
operator D*(); };
86 template <
typename B,
typename D>
89 typedef char (&yes)[1];
90 typedef char (&no)[2];
91 template <
typename T>
static yes check(D*, T);
92 static no check(B*,
int);
93 static const bool value =
sizeof(check(Host<B,D>(),
int())) ==
sizeof(yes);
97 class reference_wrapper
102 reference_wrapper(
const T& ref) : _ptr(&const_cast<T&>(ref)) { }
103 reference_wrapper(
const reference_wrapper&o) : _ptr(o._ptr) { }
105 reference_wrapper& operator=(
const reference_wrapper& o)
106 { _ptr = o._ptr;
return *
this; }
108 operator T& ()
const {
return *_ptr; }
109 T&
get()
const {
return *_ptr; }
115 template<
class T, T v>
116 struct integral_constant {
117 static const T value = v;
118 typedef T value_type;
119 typedef integral_constant type;
120 value_type operator()()
const {
return value; }
123 typedef integral_constant<bool, true> true_type;
124 typedef integral_constant<bool, false> false_type;
126 template<
typename>
struct is_integral_base : false_type {};
128 template<>
struct is_integral_base<bool> : true_type {};
129 template<>
struct is_integral_base<char> : true_type {};
130 template<>
struct is_integral_base<signed char> : true_type {};
131 template<>
struct is_integral_base<unsigned char> : true_type {};
132 template<>
struct is_integral_base<wchar_t> : true_type {};
133 template<>
struct is_integral_base<short> : true_type {};
134 template<>
struct is_integral_base<int> : true_type {};
135 template<>
struct is_integral_base<long> : true_type {};
136 template<>
struct is_integral_base<long long> : true_type {};
137 template<>
struct is_integral_base<unsigned short> : true_type {};
138 template<>
struct is_integral_base<unsigned int> : true_type {};
139 template<>
struct is_integral_base<unsigned long> : true_type {};
140 template<>
struct is_integral_base<unsigned long long> : true_type {};
142 template<
class T >
struct remove_const {
typedef T type; };
143 template<
class T >
struct remove_const<const T> {
typedef T type; };
145 template<
class T >
struct remove_volatile {
typedef T type; };
146 template<
class T >
struct remove_volatile<volatile T> {
typedef T type; };
149 struct remove_cv {
typedef typename remove_volatile<typename remove_const<T>::type>::type type; };
151 template<
typename T>
struct is_integral: is_integral_base<typename remove_cv<T>::type> {};
154 struct make_unsigned;
155 #define GISMO_MAKE_UNSIGNED(signed_type) \
157 struct make_unsigned<signed signed_type> { \
158 typedef unsigned signed_type type; \
161 struct make_unsigned<unsigned signed_type> { \
162 typedef unsigned signed_type type; \
165 struct make_unsigned<char> {
166 typedef unsigned char type;
168 GISMO_MAKE_UNSIGNED(
char)
169 GISMO_MAKE_UNSIGNED(
short)
170 GISMO_MAKE_UNSIGNED(
int)
171 GISMO_MAKE_UNSIGNED(
long)
172 GISMO_MAKE_UNSIGNED(
long long)
173 #undef GISMO_MAKE_UNSIGNED
177 #define GISMO_MAKE_SIGNED(unsigned_type) \
179 struct make_signed<signed unsigned_type> { \
180 typedef signed unsigned_type type; \
183 struct make_signed<unsigned unsigned_type> { \
184 typedef signed unsigned_type type; \
187 struct make_signed<char> {
188 typedef signed char type;
190 GISMO_MAKE_SIGNED(
char)
191 GISMO_MAKE_SIGNED(
short)
192 GISMO_MAKE_SIGNED(
int)
193 GISMO_MAKE_SIGNED(
long)
194 GISMO_MAKE_SIGNED(
long long)
195 #undef GISMO_MAKE_SIGNED
199 #define GISMO_IS_SIGNED(type) \
201 struct is_signed<signed type> { \
202 static const bool value = true; \
205 struct is_signed<unsigned type> { \
206 static const bool value = false; \
208 GISMO_IS_SIGNED(
char)
209 GISMO_IS_SIGNED(
short)
211 GISMO_IS_SIGNED(
long)
212 GISMO_IS_SIGNED(
long long)
213 #undef GISMO_IS_SIGNED
221 template<
typename T>
struct remove_pointer<T*> {
typedef typename remove_pointer<T>::type
type;};
227 template <
class T>
struct is_complex<volatile const T > :
public is_complex<T>{};
228 template <
class T>
struct is_complex<volatile T > :
public is_complex<T>{};
229 template <
class T>
struct is_complex<std::complex<T> > :
public true_type{};
246 template<
class T1,
class T2>
249 typedef typename util::make_signed<T1>::type signedT1;
250 typedef typename util::make_signed<T2>::type signedT2;
251 typedef typename util::make_unsigned<T1>::type unsignedT1;
252 typedef typename util::make_unsigned<T2>::type unsignedT2;
254 if (is_signed<T1>::value == is_signed<T2>::value)
256 if (is_signed<T1>::value)
257 return (static_cast<signedT1>(t1) < static_cast<signedT2>(t2));
259 return (static_cast<unsignedT1>(t1) < static_cast<unsignedT2>(t2));
261 if (is_signed<T1>::value && !is_signed<T2>::value)
265 return (static_cast<unsignedT1>(t1) < static_cast<unsignedT2>(t2));
267 if (!is_signed<T1>::value && is_signed<T2>::value)
271 return (static_cast<unsignedT1>(t1) < static_cast<unsignedT2>(t2));
279 template<
class T1,
class T2>
282 typedef typename util::make_signed<T1>::type signedT1;
283 typedef typename util::make_signed<T2>::type signedT2;
284 typedef typename util::make_unsigned<T1>::type unsignedT1;
285 typedef typename util::make_unsigned<T2>::type unsignedT2;
287 if (is_signed<T1>::value == is_signed<T2>::value)
289 if (is_signed<T1>::value)
290 return (static_cast<signedT1>(t1) <= static_cast<signedT2>(t2));
292 return (static_cast<unsignedT1>(t1) <= static_cast<unsignedT2>(t2));
294 if (is_signed<T1>::value && !is_signed<T2>::value)
298 return (static_cast<unsignedT1>(t1) <= static_cast<unsignedT2>(t2));
300 if (!is_signed<T1>::value && is_signed<T2>::value)
304 return (static_cast<unsignedT1>(t1) <= static_cast<unsignedT2>(t2));
312 template<
class T1,
class T2>
322 template<
class T1,
class T2>
332 template<
class T1,
class T2>
335 typedef typename util::make_signed<T1>::type signedT1;
336 typedef typename util::make_signed<T2>::type signedT2;
337 typedef typename util::make_unsigned<T1>::type unsignedT1;
338 typedef typename util::make_unsigned<T2>::type unsignedT2;
340 if (is_signed<T1>::value == is_signed<T2>::value)
342 if (is_signed<T1>::value)
343 return static_cast<signedT1
>(t1) == static_cast<signedT2>(t2);
345 return static_cast<unsignedT1
>(t1) == static_cast<unsignedT2>(t2);
347 if (is_signed<T1>::value && !is_signed<T2>::value)
351 return (static_cast<unsignedT1>(t1) ==
static_cast<unsignedT2
>(t2));
353 if (!is_signed<T1>::value && is_signed<T2>::value)
357 return (static_cast<unsignedT1>(t1) ==
static_cast<unsignedT2
>(t2));
Print name of template type as a string.
Definition: gsUtils.h:234
bool less(T1 t1, T2 t2)
Definition: gsTemplateTools.h:247
bool greater(T1 t1, T2 t2)
Definition: gsTemplateTools.h:313
bool less_equal(T1 t1, T2 t2)
Definition: gsTemplateTools.h:280
Handles shared library creation and other class attributes.
make_unsigned< T >::type to_unsigned(T t)
Casts a type T to an unsigned one.
Definition: gsTemplateTools.h:233
bool greater_equal(T1 t1, T2 t2)
Definition: gsTemplateTools.h:323
Type trait is_complex<T> checks if type T is of type std::complex<...>
Definition: gsTemplateTools.h:225
make_signed< T >::type to_signed(T t)
Casts a type T to a signed one.
Definition: gsTemplateTools.h:238
bool equal(T1 t1, T2 t2)
Definition: gsTemplateTools.h:333
Remove pointer from type.
Definition: gsTemplateTools.h:220