Vcsn  2.3
Be Rational
symbol.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vcsn/config.hh>
4 
5 #include <boost/flyweight.hpp>
6 #include <boost/flyweight/intermodule_holder.hpp>
7 #include <boost/flyweight/no_tracking.hpp>
8 
9 namespace vcsn
10 {
20  using symbol
21  = boost::flyweight<std::string,
22  boost::flyweights::no_tracking,
23  boost::flyweights::intermodule_holder>;
24 
25  inline
26  std::string operator+(symbol l, const char* r)
27  {
28  return l.get() + r;
29  }
30 
31  inline
32  std::string operator+(const char* l, symbol r)
33  {
34  return l + r.get();
35  }
36 
37  inline
38  std::string operator+(symbol l, const std::string& r)
39  {
40  return l.get() + r;
41  }
42 
43  inline
44  std::string operator+(const std::string& l, symbol r)
45  {
46  return l + r.get();
47  }
48 }
49 
50 namespace std
51 {
52  template <>
53  struct hash<vcsn::symbol>
54  {
55  size_t operator()(const vcsn::symbol& ss) const
56  {
57  // http://lists.boost.org/boost-users/2013/03/78007.php
58  hash<const void*> hasher;
59  return hasher(&ss.get());
60  }
61  };
62 }
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
Definition: symbol.hh:23
STL namespace.
return hasher(v)
std::string operator+(symbol l, const char *r)
Definition: symbol.hh:26
Definition: a-star.hh:8
size_t operator()(const vcsn::symbol &ss) const
Definition: symbol.hh:55
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
weightset_mixin< detail::r_impl > r
Definition: fwd.hh:54