Vcsn  2.4
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);
66  DEFINE(weight_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 
97  template <typename LS1, typename LS2, typename LS3>
98  struct are_labelsets_composable<tupleset<LS1, LS2>, tupleset<LS2, LS3>>
99  : std::true_type
100  {};
101 
103  template <typename Ctx1, typename Ctx2>
105  : are_labelsets_composable<labelset_t_of<Ctx1>, labelset_t_of<Ctx2>>
106  {};
107 }
Whether two labelsets are composable.
Definition: traits.hh:94
#define DEFINE(Type)
Extract various ValueSets/Value types from objects, or pointers to objects.
Definition: traits.hh:29
typename labelset_t_of< base_t< ValueSet >>::letter_t letter_t_of
Definition: traits.hh:86
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
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
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
Definition: traits.hh:63
Definition: a-star.hh:8
typename labelset_t_of< base_t< ValueSet >>::word_t word_t_of
Definition: traits.hh:90
std::remove_cv_t< std::remove_reference_t< T >> base_t
T without reference or const/volatile qualifiers.
Definition: traits.hh:13
Whether two contexts are composable.
Definition: traits.hh:104