Vcsn  2.1
Be Rational
project-automaton.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vcsn/algos/copy.hh>
4 #include <vcsn/algos/focus.hh>
5 #include <vcsn/algos/project.hh>
8 #include <vcsn/misc/name.hh> // integral_constant
9 
10 namespace vcsn
11 {
12 
13  /*----------------------.
14  | project(automaton). |
15  `----------------------*/
16 
17  template <std::size_t Tape, typename Aut>
18  auto project(const Aut& aut)
20  {
21  static_assert(Tape < labelset_t_of<Aut>::size(),
22  "project: invalid tape number");
23  auto res =
24  make_mutable_automaton(detail::make_project_context<Tape>(aut->context()));
25  copy_into(focus<Tape>(aut), res, false);
26  return res;
27  }
28 
29  namespace dyn
30  {
31  namespace detail
32  {
34  template <typename Aut, typename Tape>
35  automaton
37  {
38  const auto& a = aut->as<Aut>();
39  return make_automaton(vcsn::project<Tape::value>(a));
40  }
41  }
42  }
43 }
A simple placeholder for integral constants.
Definition: name.hh:198
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
Definition: automaton.hh:75
automaton project(const automaton &aut, integral_constant)
Bridge.
mutable_automaton< Context > make_mutable_automaton(const Context &ctx)
std::shared_ptr< detail::automaton_base > automaton
Definition: automaton.hh:69
void copy_into(const AutIn &in, AutOut &out, KeepState keep_state, KeepTrans keep_trans)
Copy selected states and transitions of an automaton.
Definition: copy.hh:126
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
Definition: traits.hh:47
auto project(const Aut &aut) -> mutable_automaton< detail::project_context< Tape, context_t_of< Aut >>>
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
Definition: fwd.hh:24