Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
is-valid-ratexp.hh
Go to the documentation of this file.
1 #ifndef VCSN_ALGOS_IS_VALID_RATEXP_HH
2 # define VCSN_ALGOS_IS_VALID_RATEXP_HH
3 
4 # include <stdexcept>
5 
7 
8 namespace vcsn
9 {
10 
11  /*-------------------.
12  | is_valid(ratexp). |
13  `-------------------*/
14 
16  template <typename RatExpSet>
17  bool
18  is_valid(const RatExpSet& rs, const typename RatExpSet::value_t& e)
19  {
20  try
21  {
22  constant_term(rs, e);
23  return true;
24  }
25  catch (const std::runtime_error&)
26  {
27  return false;
28  }
29  }
30 
31  namespace dyn
32  {
33  namespace detail
34  {
36  template <typename RatExpSet>
37  bool
38  is_valid_ratexp(const ratexp& exp)
39  {
40  const auto& e = exp->as<RatExpSet>();
41  return ::vcsn::is_valid(e.ratexpset(), e.ratexp());
42  }
43 
44  REGISTER_DECLARE(is_valid_ratexp, (const ratexp& e) -> bool);
45  }
46  }
47 } // namespace vcsn
48 
49 #endif // !VCSN_ALGOS_IS_VALID_RATEXP_HH
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::ratexp_base > ratexp
Definition: fwd.hh:64
bool is_valid(const Aut &aut)
Definition: is-valid.hh:138
bool is_valid_ratexp(const ratexp &exp)
Bridge.
weight_t_of< RatExpSet > constant_term(const RatExpSet &rs, const typename RatExpSet::value_t &e)