Vcsn  2.3
Be Rational
signature.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iosfwd>
4 #include <string>
5 
7 #include <vcsn/misc/export.hh>
9 #include <vcsn/misc/vector.hh>
10 #include <vcsn/misc/symbol.hh>
11 
12 namespace vcsn LIBVCSN_API
13 {
15  struct signature
16  {
17  using sig_t = std::vector<symbol>;
18 
19  signature() = default;
20 
21  signature(std::initializer_list<symbol> l)
22  : sig(l)
23  {}
24 
25  std::string to_string() const;
26 
27  ATTRIBUTE_PURE
28  bool operator<(const signature& that) const
29  {
30  return sig < that.sig;
31  }
32 
33  ATTRIBUTE_PURE
34  bool operator==(const signature& that) const
35  {
36  return sig == that.sig;
37  }
38 
39  sig_t::const_iterator begin() const
40  {
41  return std::begin(sig);
42  }
43 
44  sig_t::const_iterator end() const
45  {
46  return std::end(sig);
47  }
48 
49  symbol& operator[](const size_t n)
50  {
51  return sig[n];
52  }
53 
54  const symbol operator[](const size_t n) const
55  {
56  return sig.at(n);
57  }
58 
59  size_t size() const
60  {
61  return sig.size();
62  }
63 
65  };
66 
68  std::ostream& operator<<(std::ostream& os, const signature& sig);
69 }
70 
71 namespace std
72 {
73  template <>
74  struct hash<vcsn::signature>
75  {
76  size_t operator()(const vcsn::signature& sig) const
77  {
78  return vcsn::hash_value(sig.sig);
79  }
80  };
81 }
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
Definition: symbol.hh:23
STL namespace.
sig_t::const_iterator end() const
Definition: signature.hh:44
std::ostream & operator<<(std::ostream &os, direction d)
Pretty-printing.
Definition: direction.cc:19
std::vector< symbol > sig_t
Definition: signature.hh:17
auto hash_value(const T &v) -> decltype(std::hash< T >
Following the naming convention of Boost.
Definition: functional.hh:30
ATTRIBUTE_PURE bool operator<(const signature &that) const
Definition: signature.hh:28
sig_t::const_iterator begin() const
Definition: signature.hh:39
Definition: a-star.hh:8
#define LIBVCSN_API
Definition: export.hh:8
signature(std::initializer_list< symbol > l)
Definition: signature.hh:21
ATTRIBUTE_PURE bool operator==(const signature &that) const
Definition: signature.hh:34
std::string to_string() const
Definition: signature.cc:9
signature()=default
size_t size() const
Definition: signature.hh:59
Signature of a function call.
Definition: signature.hh:15
const symbol operator[](const size_t n) const
Definition: signature.hh:54
symbol & operator[](const size_t n)
Definition: signature.hh:49
std::ostringstream os
The output stream: the corresponding C++ snippet to compile.
Definition: translate.cc:375
size_t operator()(const vcsn::signature &sig) const
Definition: signature.hh:76