Vcsn  2.3
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  {
13 
21  class identities
22  {
23  public:
24  using self_t = identities;
25 
26  enum ids_t
27  {
30 
33 
36 
40 
43 
46  };
47 
49  : ids_{id}
50  {}
51 
53  identities(const std::string& i);
54 
56  identities(const char* cp);
57 
58  ids_t ids() const
59  {
60  return ids_;
61  }
62 
64  bool is_associative() const
65  {
66  return associative <= ids_;
67  }
68 
70  bool is_distributive() const
71  {
72  return distributive <= ids_;
73  }
74 
76  bool is_linear() const
77  {
78  return linear <= ids_;
79  }
80 
82  operator bool() const
83  {
84  return ids_ != none;
85  }
86 
87  bool operator<(self_t that) const
88  {
89  return ids_ < that.ids_;
90  }
91 
92  bool operator==(self_t that) const
93  {
94  return ids_ == that.ids_;
95  }
96 
97  bool operator!=(self_t that) const
98  {
99  return !operator==(that);
100  }
101 
102  private:
104  };
105 
107  std::string to_string(identities i);
108 
110  std::istream& operator>>(std::istream& is, identities& i);
111 
113  std::ostream& operator<<(std::ostream& os, identities i);
114 
116 
117  } // namespace rat
118 
119  namespace detail
120  {
121  template <>
122  struct join_impl<rat::identities, rat::identities>
123  {
126  {
127  return std::max(i1, i2);
128  }
129  };
130  }
131 } // namespace vcsn
bool is_distributive() const
Whether distributive.
Definition: identities.hh:70
Strictly obey to the syntax.
Definition: identities.hh:29
std::ostream & operator<<(std::ostream &o, type_t t)
Print a expression type.
Definition: printer.hxx:13
identities(ids_t id=deflt)
Definition: identities.hh:48
static type join(rat::identities i1, rat::identities i2)
Definition: identities.hh:125
Trivial, plus associativity of add and product.
Definition: identities.hh:35
A structure that implements the computation of join(V1, V2).
Definition: join.hh:18
bool operator<(self_t that) const
Definition: identities.hh:87
bool is_associative() const
Whether associative.
Definition: identities.hh:64
ids_t ids() const
Definition: identities.hh:58
Associative plus commutativity, and "idempotence" for add.
Definition: identities.hh:39
Traditional plus distribution. Used for series identities.
Definition: identities.hh:42
bool operator==(self_t that) const
Definition: identities.hh:92
Definition: a-star.hh:8
#define LIBVCSN_API
Definition: export.hh:8
An expressionset can implement several different sets of identities on expressions.
Definition: identities.hh:21
std::istream & operator>>(std::istream &is, identities &i)
Read from string form.
Definition: identities.cc:64
bool is_linear() const
Whether linear.
Definition: identities.hh:76
The default value.
Definition: identities.hh:45
std::string to_string(identities i)
Wrapper around operator<<.
Definition: identities.cc:41
identities meet(identities i1, identities i2)
Definition: identities.cc:73
Trivial identities only.
Definition: identities.hh:32
bool operator!=(self_t that) const
Definition: identities.hh:97
std::ostringstream os
The output stream: the corresponding C++ snippet to compile.
Definition: translate.cc:375