Orxonox  0.0.5 Codename: Arcturus
is_callable.h
Go to the documentation of this file.
1 #ifndef IS_CALLABLE_H
2 #define IS_CALLABLE_H
3 
4 #include <type_traits>
5 
9 template<typename T>
11 {
12 private:
13  typedef char(&yes)[1];
14  typedef char(&no)[2];
15 
16  struct Fallback { void operator()(); };
17  struct Derived : T, Fallback { };
18 
19  template<typename U, U> struct Check;
20 
21  template<typename>
22  static yes test(...);
23 
24  template<typename C>
25  static no test(Check<void (Fallback::*)(), &C::operator()>*);
26 
27 public:
28  static const bool value = sizeof(test<Derived>(0)) == sizeof(yes);
29 };
30 
39 template<typename T>
40 struct IsCallable
41  : std::conditional<
42  std::is_class<T>::value,
43  IsCallableImpl<T>,
44  std::false_type
45  >::type
46 { };
47 
48 #endif // IS_CALLABLE_H
Implementation of IsCallable.
Definition: is_callable.h:10
Definition: is_callable.h:17
char(& no)[2]
Definition: is_callable.h:14
static yes test(...)
Definition: is_callable.h:19
Checks if a type is callable.
Definition: is_callable.h:40
Definition: InputPrereqs.h:78
static const bool value
Definition: is_callable.h:28
Definition: is_callable.h:16
char(& yes)[1]
Definition: is_callable.h:13