Vcsn  2.2
Be Rational
is-valid-expression.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdexcept>
4 
6 
7 namespace vcsn
8 {
9 
10  /*------------------------.
11  | is_valid(expression). |
12  `------------------------*/
13 
15  template <typename ExpSet>
16  bool
17  is_valid(const ExpSet& rs, const typename ExpSet::value_t& e)
18  {
19  try
20  {
21  constant_term(rs, e);
22  return true;
23  }
24  catch (const std::runtime_error&)
25  {
26  return false;
27  }
28  }
29 
30  namespace dyn
31  {
32  namespace detail
33  {
35  template <typename ExpSet>
36  bool
38  {
39  const auto& e = exp->as<ExpSet>();
40  return ::vcsn::is_valid(e.expressionset(), e.expression());
41  }
42  }
43  }
44 } // namespace vcsn
bool is_valid_expression(const expression &exp)
Bridge (is_valid).
Definition: a-star.hh:8
weight_t_of< ExpSet > constant_term(const ExpSet &rs, const typename ExpSet::value_t &e)
The constant term of e.
auto rs
Definition: lift.hh:151
bool is_valid(const Aut &aut)
Definition: is-valid.hh:141
std::shared_ptr< detail::expression_base > expression
Definition: expression.hh:92