Samchon Framework for CPP  1.0.0
IndexPair.hpp
1 #pragma once
2 
3 #include <utility>
4 
5 namespace samchon
6 {
29  template<class T>
30  class IndexPair
31  : public std::pair<size_t, T>
32  {
33  private:
34  typedef std::pair<size_t, T> super;
35 
36  public:
37  /* -----------------------------------------------------------
38  CONSTRUCTORS
39  ----------------------------------------------------------- */
40  //using super::super;
41 
46  : super()
47  {
48  };
49 
53  template<class U> IndexPair(const IndexPair<U> &obj)
54  : super(obj)
55  {
56  };
57 
61  template<class U> IndexPair(const IndexPair<U> &&obj)
62  : super(obj)
63  {
64  };
65 
69  IndexPair(size_t index, const T &val)
70  : super(index, val)
71  {
72  };
73 
74  /* -----------------------------------------------------------
75  GETTERS
76  ----------------------------------------------------------- */
82  auto get_index() const -> size_t
83  {
84  return first;
85  };
86 
92  auto getValue() -> T&
93  {
94  return second;
95  };
96 
102  auto getValue() const -> const T&
103  {
104  return second;
105  };
106  };
107 };
IndexPair()
Default Constructor.
Definition: IndexPair.hpp:45
IndexPair(const IndexPair< U > &&obj)
Move Constructor.
Definition: IndexPair.hpp:61
auto getValue() -> T &
Get reference of value.
Definition: IndexPair.hpp:92
IndexPair(size_t index, const T &val)
Construct from members.
Definition: IndexPair.hpp:69
IndexPair(const IndexPair< U > &obj)
Copy Constructor.
Definition: IndexPair.hpp:53
A pair of index and its value(T)
Definition: IndexPair.hpp:30
auto getValue() const -> const T &
Get const reference of const value.
Definition: IndexPair.hpp:102
auto get_index() const -> size_t
Get index.
Definition: IndexPair.hpp:82