Vcsn  2.5
Be Rational
identities.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <string>
5 
6 #include <vcsn/core/join.hh>
7 #include <vcsn/misc/export.hh>
8 
9 namespace vcsn LIBVCSN_API
10 {
11  namespace rat
12  {
20  class identities
21  {
22  public:
23  using self_t = identities;
24 
25  enum ids_t
26  {
29 
32 
35 
39 
42 
45 
48  };
49 
51  : ids_{id}
52  {}
53 
55  identities(const std::string& i);
56 
58  identities(const char* cp);
59 
60  ids_t ids() const
61  {
62  return ids_;
63  }
64 
66  bool is_agressive() const
67  {
68  return ids_ == agressive;
69  }
70 
72  bool is_associative() const
73  {
74  return associative <= ids_;
75  }
76 
78  bool is_distributive() const
79  {
80  return ids_ == distributive;
81  }
82 
84  bool is_linear() const
85  {
86  return linear <= ids_;
87  }
88 
90  operator bool() const
91  {
92  return ids_ != none;
93  }
94 
95  bool operator<(self_t that) const
96  {
97  return ids_ < that.ids_;
98  }
99 
100  bool operator==(self_t that) const
101  {
102  return ids_ == that.ids_;
103  }
104 
105  bool operator!=(self_t that) const
106  {
107  return !operator==(that);
108  }
109 
110  private:
112  };
113 
115  std::string to_string(identities i);
116 
118  std::istream& operator>>(std::istream& is, identities& i);
119 
121  std::ostream& operator<<(std::ostream& os, identities i);
122 
124 
125  } // namespace rat
126 
127  namespace detail
128  {
129  template <>
131  {
134  {
135  return std::max(i1, i2);
136  }
137  };
138  }
139 } // namespace vcsn
bool operator==(self_t that) const
Definition: identities.hh:100
std::ostringstream os
The output stream: the corresponding C++ snippet to compile.
Definition: translate.cc:381
::vcsn::rat::identities identities
Sets of identities on expressions.
Definition: fwd.hh:17
bool is_agressive() const
Whether agressive optimizations are on.
Definition: identities.hh:66
Definition: a-star.hh:8
Trivial, plus associativity of add and product.
Definition: identities.hh:34
identities meet(identities i1, identities i2)
Definition: identities.cc:76
Associative plus commutativity, and "idempotence" for add.
Definition: identities.hh:38
bool is_linear() const
Whether linear.
Definition: identities.hh:84
An expressionset can implement several different sets of identities on expressions.
Definition: identities.hh:20
Linear plus optimizations.
Definition: identities.hh:44
bool is_distributive() const
Whether distributive.
Definition: identities.hh:78
Linear plus distribution. Used for series identities.
Definition: identities.hh:41
bool is_associative() const
Whether associative.
Definition: identities.hh:72
std::string to_string(identities i)
Wrapper around operator<<.
Definition: identities.cc:42
Trivial identities only.
Definition: identities.hh:31
std::ostream & operator<<(std::ostream &o, type_t t)
Print a expression type.
Definition: printer.hxx:13
ids_t ids() const
Definition: identities.hh:60
The default value.
Definition: identities.hh:47
A structure that implements the computation of join(V1, V2).
Definition: join.hh:18
std::istream & operator>>(std::istream &is, identities &i)
Read from string form.
Definition: identities.cc:67
static type join(rat::identities i1, rat::identities i2)
Definition: identities.hh:133
#define LIBVCSN_API
Definition: export.hh:8
Strictly obey to the syntax.
Definition: identities.hh:28
bool operator<(self_t that) const
Definition: identities.hh:95
identities(ids_t id=deflt)
Definition: identities.hh:50
bool operator!=(self_t that) const
Definition: identities.hh:105