Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
meta.h
1 /*
2  * $Id$
3  * Copyright (c) 2006, IRIT-UPS.
4  *
5  * Meta-programming definitions.
6  */
7 #ifndef ELM_META_H
8 #define ELM_META_H
9 
10 
11 namespace elm {
12 
13 namespace meta {
14 
15  template <int x> struct n { enum { _ = x }; };
16  struct _true { enum { _ = 1 }; };
17  struct _false { enum { _ = 0 }; };
18 
19  template <bool c, class T, class E> struct _if: public T { };
20  template <class T, class E> struct _if<false, T, E>: public E { };
21 
22  template <class> struct sfinae_true: _true { };
23  template <class T> inline T& declval() { return *static_cast<T *>(nullptr); }
24 
25  template <typename U, typename t> struct is_same: _false { };
26  template <typename U> struct is_same<U, U>: _true { };
27 
28  template <typename T, template <typename X> class C>
29  struct is_supported {
30  template <class U> static _true c(C<U> *);
31  template <class U> static _false c(...);
32  enum { _ = decltype(c<T>(0))::_ };
33  };
34 
35  template<bool B, class T = void> struct enable_if {};
36  template<class T> struct enable_if<true, T> { typedef T _; };
37 }
38 
39 // deprecated
40 template <int x> struct _n { enum { _ = x }; };
41 struct _true { enum { _ = 1 }; };
42 struct _false { enum { _ = 0 }; };
43 template <bool c, class T, class E> struct _if: public T { };
44 template <class T, class E> struct _if<false, T, E>: public E { };
45 
46 } // elm
47 
48 #endif // ELM_META_H
49 
elm::_false::_
@ _
Definition: meta.h:42
elm::_if
Definition: meta.h:43
elm::meta::_true
Definition: meta.h:16
elm::meta::sfinae_true
Definition: meta.h:22
elm::meta::n::_
@ _
Definition: meta.h:15
elm::_false
Definition: meta.h:42
elm::meta::enable_if
Definition: meta.h:35
elm::meta::_false::_
@ _
Definition: meta.h:17
elm::_n::_
@ _
Definition: meta.h:40
elm::meta::declval
T & declval()
Definition: meta.h:23
elm::_true
Definition: meta.h:41
elm::_n
Definition: meta.h:40
elm::meta::is_supported::c
static _true c(C< U > *)
elm::_true::_
@ _
Definition: meta.h:41
elm::meta::_false
Definition: meta.h:17
elm::meta::enable_if< true, T >::_
T _
Definition: meta.h:36
elm
Definition: adapter.h:26
elm::meta::is_same
Definition: meta.h:25
elm::meta::is_supported::_
@ _
Definition: meta.h:32
elm::meta::_if
Definition: meta.h:19
elm::meta::n
Definition: meta.h:15
elm::meta::_true::_
@ _
Definition: meta.h:16
elm::meta::is_supported
Definition: meta.h:29