Vcsn  2.2
Be Rational
tuple.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vcsn/core/rat/fwd.hh>
4 #include <vcsn/dyn/expansion.hh>
5 
6 namespace vcsn
7 {
8  /*-----------------------------.
9  | tuple_context(context...). |
10  `-----------------------------*/
11 
12  template <typename... Ctx>
13  auto
14  tuple_context(Ctx&&... ctx)
17  {
18  auto ls = make_tupleset(*ctx.labelset()...);
19  auto ws = join(*ctx.weightset()...);
20  return {ls, ws};
21  }
22 
23 
24  /*---------------------------------------.
25  | tuple_expansionset(expansionset...). |
26  `---------------------------------------*/
27 
28  template <typename... ExpansionSets>
29  auto
30  tuple_expansionset(const ExpansionSets&... ess)
31  -> rat::expansionset<decltype(tuple_expressionset(ess.expressionset()...))>
32  {
33  return {tuple_expressionset(ess.expressionset()...)};
34  }
35 
36  /*------------------------.
37  | tuple(expression...). |
38  `------------------------*/
39 
40  template <typename ValueSet, typename... ValueSets>
41  inline
42  typename ValueSet::value_t
43  tuple(const ValueSet& vs,
44  const typename ValueSets::value_t&... v)
45  {
46  return vs.tuple(v...);
47  }
48 
49  /*-----------------------------------------.
50  | tuple_expressionset(expressionset...). |
51  `-----------------------------------------*/
52 
53  template <typename... ExpSets>
54  auto
55  tuple_expressionset(const ExpSets&... rss)
56  -> expressionset<decltype(tuple_context(rss.context()...))>
57  {
58  auto ctx = tuple_context(rss.context()...);
59  auto ids = join(rss.identities()...);
60  return {ctx, ids};
61  }
62 
63  /*-----------------------.
64  | tuple(expansion...). |
65  `-----------------------*/
66 
67  namespace dyn
68  {
69  namespace detail
70  {
72  template <typename ExpansionSets, size_t... I>
73  expansion
74  tuple_(const std::vector<expansion>& es,
76  {
77  auto xs
79  (es[I]
80  ->template as<tuple_element_t<I, ExpansionSets>>()
81  .expansionset()...);
82  return
84  (xs,
86  (xs,
87  es[I]
88  ->template as<tuple_element_t<I, ExpansionSets>>()
89  .expansion()...));
90  }
91 
93  template <typename ExpansionSets>
94  expansion
95  tuple_expansion(const std::vector<expansion>& es)
96  {
97  auto indices
99  return tuple_<ExpansionSets>(es, indices);
100  }
101  }
102  }
103 
104  /*------------------------.
105  | tuple(expression...). |
106  `------------------------*/
107 
108  namespace dyn
109  {
110  namespace detail
111  {
113  template <typename ExpSets, size_t... I>
114  expression
115  tuple_(const std::vector<expression>& es,
117  {
118  auto rs
120  (es[I]
121  ->template as<tuple_element_t<I, ExpSets>>()
122  .expressionset()...);
123  return
125  (rs,
127  (rs,
128  es[I]
129  ->template as<tuple_element_t<I, ExpSets>>()
130  .expression()...));
131  }
132 
134  template <typename ExpSets>
135  expression
136  tuple_expression(const std::vector<expression>& es)
137  {
138  auto indices
140  return tuple_<ExpSets>(es, indices);
141  }
142  }
143  }
144 }
ValueSet::value_t tuple(const ValueSet &vs, const typename ValueSets::value_t &...v)
Definition: tuple.hh:43
auto join(const ValueSet &vs) -> ValueSet
The join of a single valueset.
Definition: join.hh:44
weightset_mixin< rat::expressionset_impl< Context >> expressionset
Definition: fwd.hh:200
auto tuple_expansionset(const ExpansionSets &...ess) -> rat::expansionset< decltype(tuple_expressionset(ess.expressionset()...))>
Definition: tuple.hh:30
decltype(join(std::declval< ValueSets >()...)) join_t
The type of the join of the ValueSets.
Definition: join.hh:79
Definition: a-star.hh:8
std::shared_ptr< const detail::expansion_base > expansion
Definition: expansion.hh:73
auto tuple_expressionset(const ExpSets &...rss) -> expressionset< decltype(tuple_context(rss.context()...))>
Definition: tuple.hh:55
tupleset< ValueSets... > make_tupleset(const ValueSets &...vss)
Definition: tupleset.hh:1053
auto tuple_context(Ctx &&...ctx) -> context< tupleset< labelset_t_of< Ctx >... >, join_t< weightset_t_of< Ctx >... >>
Definition: tuple.hh:14
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
rat::expansionset< ExpSet > expansionset
Definition: fwd.hh:203
typename std::tuple_element< I, T >::type tuple_element_t
C++14.
Definition: tuple.hh:14
auto rs
Definition: lift.hh:151
expression tuple_expression(const std::vector< expression > &es)
Bridge (tuple).
Definition: tuple.hh:136
expansion tuple_(const std::vector< expansion > &es, vcsn::detail::index_sequence< I... >)
Bridge helper.
Definition: tuple.hh:74
expansion tuple_expansion(const std::vector< expansion > &es)
Bridge (tuple).
Definition: tuple.hh:95
static dyn::context ctx(const driver &d)
Get the context of the driver.
Definition: parse.cc:82
std::shared_ptr< detail::expression_base > expression
Definition: expression.hh:92
expansion make_expansion(const ExpansionSet &ps, const typename ExpansionSet::value_t &expansion)
Definition: expansion.hh:78
static identities ids(const driver &d)
Get the identities of the driver.
Definition: parse.cc:89
expression make_expression(const ExpSet &rs, const typename ExpSet::value_t &r)
Definition: expression.hh:97