Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
traits.hh
Go to the documentation of this file.
1 #ifndef VCSN_CTX_TRAITS_HH
2 # define VCSN_CTX_TRAITS_HH
3 
4 # include <memory>
5 
6 namespace vcsn
7 {
8 
10  template <typename T>
11  using base_t
12  = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
13 
14  /*------------------.
15  | Computing types. |
16  `------------------*/
17 
18 # define DEFINE(Type) \
19  namespace detail \
20  { \
21  template <typename ValueSet> \
22  struct Type ## _of_impl \
23  { \
24  using type = typename ValueSet::Type; \
25  }; \
26  } \
27  \
28  template <typename ValueSet> \
29  using Type ## _of \
30  = typename detail::Type ## _of_impl<base_t<ValueSet>>::type
31 
32  DEFINE(context_t);
34  DEFINE(labelset_t);
35  DEFINE(state_t);
36  DEFINE(transition_t);
37  DEFINE(weight_t);
38  DEFINE(weightset_t);
39 
40 # undef DEFINE
41 
42 
43  /*------------------.
44  | shared pointers. |
45  `------------------*/
46 
47  // Forward traits about shared_ptr<T> to T.
48  namespace detail
49  {
50 # define DEFINE(Traits) \
51  template <typename ValueSet> \
52  struct Traits ## _of_impl<std::shared_ptr<ValueSet>> \
53  : Traits ## _of_impl<base_t<ValueSet>> \
54  {}
55 
56  DEFINE(context_t);
58  DEFINE(labelset_t);
59  DEFINE(state_t);
60  DEFINE(transition_t);
61  DEFINE(weight_t);
62  DEFINE(weightset_t);
63 # undef DEFINE
64  }
65 }
66 
67 #endif // !VCSN_CTX_TRAITS_HH
#define DEFINE(Type)
Definition: traits.hh:50
typename std::remove_cv< typename std::remove_reference< T >::type >::type base_t
T without reference or const/volatile qualifiers.
Definition: traits.hh:12