Vcsn  2.1
Be Rational
project.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vcsn/dyn/context.hh>
5 #include <vcsn/misc/name.hh> // integral_constant
6 
7 namespace vcsn
8 {
9 
10  /*-----------------.
11  | project_context. |
12  `-----------------*/
13 
14  namespace detail
15  {
17  template <size_t Tape,
18  typename LabelSet, typename WeightSet>
22  {
23  static_assert(Tape < LabelSet::size(),
24  "project: tape index out of bounds");
25  return {ctx.labelset()->template set<Tape>(), *ctx.weightset()};
26  }
27 
30  template <size_t Tape,
31  typename LabelSet, typename WeightSet>
35  {
36  static_assert(Tape == 0,
37  "project: cannot extract non-0 tape from a non tupleset"
38  " labelset");
39  return ctx;
40  }
41  }
42 
43 
44  /*------------------------.
45  | project(expressionset). |
46  `------------------------*/
47 
48  namespace detail
49  {
50  template <size_t Tape, typename Context>
53  {
54  return {make_project_context<Tape>(rs.context()),
55  rs.identities()};
56  }
57  }
58 
59  namespace dyn
60  {
61  namespace detail
62  {
64  template <typename Context, typename Tape>
65  context
67  {
68  auto& c = ctx->as<Context>();
69  return make_context(vcsn::detail::make_project_context<Tape::value>(c));
70  }
71  }
72  }
73 }
std::shared_ptr< const detail::context_base > context
A dyn::context.
Definition: fwd.hh:41
context make_context(const std::string &name)
Bridge.
Definition: make-context.hh:44
typename std::enable_if< Cond, T >::type enable_if_t
Definition: type_traits.hh:16
A simple placeholder for integral constants.
Definition: name.hh:198
context project_context(const context &ctx, integral_constant)
Bridge (project).
Definition: project.hh:66
static dyn::context ctx(const driver &d)
Get the context of the driver.
Definition: parse.cc:80
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)
auto rs
Definition: lift.hh:151
auto make_project_context(const context< LabelSet, WeightSet > &ctx) -> enable_if_t< context< LabelSet, WeightSet >::is_lat, project_context< Tape, context< LabelSet, WeightSet >>>
The resulting apparent context when keeping only tape Tape.
Definition: project.hh:19
auto make_project(const expressionset< Context > &rs) -> expressionset< decltype(make_project_context< Tape >(rs.context()))>
Definition: project.hh:51