Platform.Data.Doublets C++
Loading...
Searching...
No Matches
Doublet.h
Go to the documentation of this file.
2{
3 // todo! use link concept
4 template <typename T>
5 struct Doublet
6 {
7 public:
8 T Source = 0;
9
10 public:
11 T Target = 0;
12
13 public:
14 Doublet(T source = 0, T target = 0) : Source(source), Target(target) {}
15
16 public:
17 explicit operator std::string() const
18 {
19 return std::string("")
20 .append(Platform::Converters::To<std::string>(Source))
21 .append("->")
22 .append(Platform::Converters::To<std::string>(Target));
23 }
24
25 public:
26 friend std::ostream& operator<<(std::ostream& stream, const Doublet<T>& self)
27 {
28 return stream << static_cast<std::string>(self);
29 }
30
31 public:
32 bool operator==(const Doublet<T>& other) const = default;
33 };
34
35 template <typename... Args>
36 Doublet(Args...) -> Doublet<std::common_type_t<Args...>>;
37} // namespace Platform::Data::Doublets
38
39template <typename T>
40struct std::hash<Platform::Data::Doublets::Doublet<T>>
41{
42 std::size_t operator()(const Platform::Data::Doublets::Doublet<T>& self) const
43 {
44 return Platform::Hashing::Hash(self.Source, self.Target);
45 }
46};
Definition TargetMatcher.h:2
Definition TargetMatcher.h:2
Definition Doublet.h:6
bool operator==(const Doublet< T > &other) const =default
Doublet(T source=0, T target=0)
Definition Doublet.h:14
T Source
Definition Doublet.h:8
friend std::ostream & operator<<(std::ostream &stream, const Doublet< T > &self)
Definition Doublet.h:26
T Target
Definition Doublet.h:11
std::size_t operator()(const Platform::Data::Doublets::Doublet< T > &self) const
Definition Doublet.h:42