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