Vcsn  2.2
Be Rational
index.hh
Go to the documentation of this file.
1 #pragma once
2 
3 namespace vcsn
4 {
5  namespace detail
6  {
8  template <typename Tag>
9  struct index_t_impl
10  {
11  index_t_impl(unsigned i)
12  : s{i}
13  {}
14 
15  // Disallow index1_t i{index2_t{42}};
16  template <typename T>
17  index_t_impl(index_t_impl<T> t) = delete;
18 
19  bool operator==(index_t_impl t) const
20  {
21  return s == t.s;
22  }
23 
24  // Disallow index1_t{42} == index2_t{42};
25  template <typename T>
26  bool operator==(index_t_impl<T> t) const = delete;
27 
29  index_t_impl() = default;
30  operator unsigned() const { return s; }
32  index_t_impl& operator++() { ++s; return *this; }
34  index_t_impl& operator--() { --s; return *this; }
35 
36  private:
37  unsigned s;
38  };
39  }
40 }
41 
42 namespace std
43 {
45  template <typename Tag>
46  struct hash<vcsn::detail::index_t_impl<Tag>>
47  {
49  size_t operator()(index_t s) const noexcept
50  {
51  return static_cast<size_t>(static_cast<unsigned>(s));
52  }
53  };
54 }
index_t_impl(unsigned i)
Definition: index.hh:11
index_t_impl & operator--()
Be compliant with Boost integer ranges.
Definition: index.hh:34
Definition: a-star.hh:8
STL namespace.
index_t_impl()=default
Default ctor to please containers.
index_t_impl & operator++()
Be compliant with Boost integer ranges.
Definition: index.hh:32
bool operator==(index_t_impl t) const
Definition: index.hh:19
size_t operator()(index_t s) const noexcept
Definition: index.hh:49
Lightweight state/transition handle (or index).
Definition: index.hh:9