Vcsn  2.3
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/dyn/name.hh> // integral_constant
9 
10 namespace vcsn
11 {
12 
13  /*----------------------.
14  | project(automaton). |
15  `----------------------*/
16 
17  template <std::size_t Tape, Automaton 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 = make_mutable_automaton(detail::project<Tape>(aut->context()));
24  copy_into(focus<Tape>(aut), res, false);
25  return res;
26  }
27 
28  namespace dyn
29  {
30  namespace detail
31  {
33  template <Automaton Aut, typename Tape>
34  automaton
36  {
37  const auto& a = aut->as<Aut>();
38  return vcsn::project<Tape::value>(a);
39  }
40  }
41  }
42 }
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
Definition: fwd.hh:25
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
Definition: traits.hh:63
auto project(const Aut &aut) -> mutable_automaton< detail::project_context< Tape, context_t_of< Aut >>>
return res
Definition: multiply.hh:398
Definition: a-star.hh:8
A dyn automaton.
Definition: automaton.hh:17
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:267
A simple placeholder for integral constants.
Definition: name.hh:196
auto & as()
Extract wrapped typed automaton.
Definition: automaton.hh:37
automaton project(const automaton &aut, integral_constant)
Bridge.
mutable_automaton< Context > make_mutable_automaton(const Context &ctx)