aimstil  5.0.5
cat2type.h
Go to the documentation of this file.
1 #ifndef TIL_CAT2TYPE_H_
2 #define TIL_CAT2TYPE_H_
3 
4 // includes from BOOST
5 #include <boost/utility/enable_if.hpp>
6 
7 // includes from TIL
8 #include "til/til_common.h"
9 
13 // Right now, only binary tests -- I dunno if it's wise to go further... :/
14 // Actually, maybe the only safe way to generalize to more tests is to use a combination
15 // of binary tests. And that can be used straight away, by using several labels as
16 // function parameters.
17 
18 namespace til
19 {
20  namespace label
21  {
23  template < template <typename> class TIS_A >
24  struct Passed
25  {};
26 
28  template < template <typename> class TIS_A >
29  struct Failed
30  {};
31  }
32 
33  namespace detail
34  {
35  template < template <typename> class TIS_A, typename T, bool B >
37  { typedef label::Failed<TIS_A> type; };
38 
39  template < template <typename> class TIS_A, typename T >
40  struct test_whether_impl<TIS_A, T, true>
41  { typedef label::Passed<TIS_A> type; };
42  }
43 
46  template < template <typename> class TIS_A, typename T >
47  struct test_whether
48  : public detail::test_whether_impl<TIS_A, T, TIS_A<T>::value>
49  {};
50 
52  template < template <typename> class TIS_A, typename T >
53  inline
56  {
57  typedef typename test_whether<TIS_A,T>::type TReturn;
58  return TReturn();
59  }
60 
61  /*
62  template < template <typename> class TIS_A, typename T >
63  inline
64  typename boost::enable_if<TIS_A<T>, label::Passed<TIS_A> >::type
65  cat2type()
66  {
67  return label::Passed<TIS_A>();
68  }
69 
70  template < template <typename> class TIS_A, typename T >
71  inline
72  typename boost::disable_if<TIS_A<T>, label::Failed<TIS_A> >::type
73  cat2type()
74  {
75  return label::Failed<TIS_A>();
76  }
77  */
78 
79 } // namespace til
80 
81 
82 #endif /*CAT2TYPE_H_*/
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
General macros, definitions and functions.
test_whether< TIS_A, T >::type cat2type()
Do an is_a test.
Definition: cat2type.h:55
A structure used for is_a tests.
Definition: cat2type.h:47
label::Failed< TIS_A > type
Definition: cat2type.h:37
A label corresponding to a positive answer of a specific is_a test.
Definition: cat2type.h:24
A label corresponding to a negative answer of a specific is_a test.
Definition: cat2type.h:29