Vcsn  2.2a
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 
52  ids_t ids() const
53  {
54  return ids_;
55  }
56 
58  bool is_associative() const
59  {
60  return associative <= ids_;
61  }
62 
64  bool is_distributive() const
65  {
66  return distributive <= ids_;
67  }
68 
70  bool is_linear() const
71  {
72  return linear <= ids_;
73  }
74 
76  operator bool() const
77  {
78  return ids_ != none;
79  }
80 
81  bool operator<(self_t that) const
82  {
83  return ids_ < that.ids_;
84  }
85 
86  bool operator==(self_t that) const
87  {
88  return ids_ == that.ids_;
89  }
90 
91  bool operator!=(self_t that) const
92  {
93  return !operator==(that);
94  }
95 
96  private:
98  };
99 
101  std::string to_string(identities i);
102 
104  std::istream& operator>>(std::istream& is, identities& i);
105 
107  std::ostream& operator<<(std::ostream& os, identities i);
108 
110 
111  } // namespace rat
112 
113  namespace detail
114  {
115  template <>
117  {
120  {
121  return std::max(i1, i2);
122  }
123  };
124  }
125 } // namespace vcsn
std::istringstream is
The input stream: the specification to translate.
Definition: translate.cc:380
#define LIBVCSN_API
Definition: export.hh:8
Traditional plus distribution. Used for series identities.
Definition: identities.hh:42
A structure that implements the computation of join(V1, V2).
Definition: join.hh:18
bool operator<(self_t that) const
Definition: identities.hh:81
rat::identities identities(const expression &exp)
Bridge.
Definition: identities.hh:19
Associative plus commutativity, and "idempotence" for sum.
Definition: identities.hh:39
identities(ids_t id=deflt)
Definition: identities.hh:48
static type join(rat::identities i1, rat::identities i2)
Definition: identities.hh:119
std::ostream & operator<<(std::ostream &o, type_t t)
Definition: printer.hxx:13
std::ostringstream os
The output stream: the corresponding C++ snippet to compile.
Definition: translate.cc:382
Strictly obey to the syntax.
Definition: identities.hh:29
bool operator==(self_t that) const
Definition: identities.hh:86
bool is_associative() const
Whether associative.
Definition: identities.hh:58
ids_t ids() const
Definition: identities.hh:52
Trivial identities only.
Definition: identities.hh:32
Trivial, plus associativity of sum and product.
Definition: identities.hh:35
bool is_linear() const
Whether linear.
Definition: identities.hh:70
std::string to_string(identities i)
Wrapper around operator<<.
Definition: identities.cc:17
bool operator!=(self_t that) const
Definition: identities.hh:91
identities meet(identities i1, identities i2)
Definition: identities.cc:72
std::istream & operator>>(std::istream &is, identities &i)
Read from string form.
Definition: identities.cc:64
The default value.
Definition: identities.hh:45
bool is_distributive() const
Whether distributive.
Definition: identities.hh:64
An expressionset can implement several different sets of identities on expressions.
Definition: identities.hh:21
Definition: a-star.hh:8