Vcsn  2.8
Be Rational
traits.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 
5 #include <vcsn/labelset/fwd.hh> // tupleset.
7 
8 namespace vcsn
9 {
10 
12  template <typename T>
13  using base_t = std::remove_cv_t<std::remove_reference_t<T>>;
14 
15  /*------------------.
16  | Computing types. |
17  `------------------*/
18 
28 
29 #define DEFINE(Type) \
30  namespace detail \
31  { \
32  template <typename ValueSet, typename = void_t<>> \
33  struct Type ## _of_impl; \
34  \
35  template <typename ValueSet> \
36  struct Type ## _of_impl<ValueSet, \
37  void_t<typename ValueSet::Type>> \
38  { \
39  using type = typename ValueSet::Type; \
40  }; \
41  \
42  template <typename ValueSet> \
43  struct Type ## _of_impl<std::shared_ptr<ValueSet>, \
44  void_t<typename ValueSet::Type>> \
45  { \
46  using type = typename ValueSet::Type; \
47  }; \
48  \
49  template <typename ValueSet> \
50  struct Type ## _of_impl<ValueSet*, \
51  void_t<typename ValueSet::Type>> \
52  { \
53  using type = typename ValueSet::Type; \
54  }; \
55  } \
56  \
57  template <typename ValueSet> \
58  using Type ## _of \
59  = typename detail::Type ## _of_impl<base_t<ValueSet>>::type
60 
61  DEFINE(context_t);
62  DEFINE(label_t);
63  DEFINE(labelset_t);
64  DEFINE(state_t);
65  DEFINE(transition_t);
67  DEFINE(weightset_t);
68 
69 #undef DEFINE
70 
80  template <typename Aut, typename Context = context_t_of<Aut>>
82  = typename Aut::element_type::template fresh_automaton_t<Context>;
83 
84  template <typename ValueSet>
85  using letter_t_of
86  = typename labelset_t_of<base_t<ValueSet>>::letter_t;
87 
88  template <typename ValueSet>
89  using word_t_of
90  = typename labelset_t_of<base_t<ValueSet>>::word_t;
91 
93  template <typename LS1, typename LS2>
94  struct are_labelsets_composable : std::false_type
95  {};
96 
99  template <typename... LS1, typename... LS2>
100  struct are_labelsets_composable<tupleset<LS1...>, tupleset<LS2...>>
101  : std::is_same<typename tupleset<LS1...>::template valueset_t<sizeof...(LS1) - 1>,
102  typename tupleset<LS2...>::template valueset_t<0>>
103  {};
104 
106  template <typename Ctx1, typename Ctx2 = Ctx1>
108  : are_labelsets_composable<labelset_t_of<Ctx1>, labelset_t_of<Ctx2>>
109  {};
110 
111  /*----------------.
112  | is_multitape. |
113  `----------------*/
114 
116  template <typename ValueSet>
118  : std::false_type
119  {};
120 
121 
122  /*-------------------.
123  | Number of tapes. |
124  `-------------------*/
125 
126  template <typename LabelSet>
128  {
129  constexpr static auto value = 0;
130  };
131 }
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
Whether two contexts are composable.
Definition: traits.hh:107
typename labelset_t_of< base_t< ValueSet > >::letter_t letter_t_of
Definition: traits.hh:86
typename detail::labelset_t_of_impl< base_t< ValueSet > >::type labelset_t_of
Definition: traits.hh:63
std::remove_cv_t< std::remove_reference_t< T > > base_t
T without reference or const/volatile qualifiers.
Definition: traits.hh:13
Definition: a-star.hh:8
typename labelset_t_of< base_t< ValueSet > >::word_t word_t_of
Definition: traits.hh:90
Whether a ValueSet, or a context, is multitape.
Definition: traits.hh:117
Whether two labelsets are composable.
Definition: traits.hh:94
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
Given an automaton type, the type of its copies.
Definition: traits.hh:82
#define DEFINE(Type)
Extract various ValueSets/Value types from objects, or pointers to objects.
Definition: traits.hh:29