OpenBarnyard
 
Loading...
Searching...
No Matches
T2Pair.h
Go to the documentation of this file.
1#pragma once
2#include "Toshi/TComparator.h"
3
5
6template <class First, class Second, class Comparator = TComparator<First>>
7struct T2Pair
8{
9 First first;
10 Second second;
11
12 constexpr T2Pair()
13 : first( First() )
14 , second( Second() )
15 {}
16
17 constexpr T2Pair( const First& a_rcFirst, const Second& a_rcSecond )
18 : first( a_rcFirst )
19 , second( a_rcSecond )
20 {}
21
22 constexpr T2Pair( const First& a_rcFirst )
23 : first( a_rcFirst )
24 , second( Second() )
25 {}
26
27 constexpr T2Pair( First&& a_rFirst )
28 : first( a_rFirst )
29 , second( Second() )
30 {}
31
32 constexpr T2Pair( const First& a_rcFirst, Second&& a_rSecond )
33 : first( a_rcFirst )
34 , second( a_rSecond )
35 {}
36
37 constexpr T2Pair( First&& a_rFirst, Second&& a_rSecond )
38 : first( a_rFirst )
39 , second( a_rSecond )
40 {}
41
42 constexpr First& GetFirst() { return first; }
43 constexpr Second& GetSecond() { return second; }
44
45 constexpr T2Pair& operator=( const T2Pair<First, Second, Comparator>& a_rcOther )
46 {
47 if ( this != &a_rcOther )
48 {
49 first = a_rcOther.first;
50 second = a_rcOther.second;
51 }
52
53 return *this;
54 }
55
56 constexpr TBOOL operator==( const T2Pair<First, Second, Comparator>& other ) const
57 {
58 return Comparator::IsEqual( first, other.first );
59 }
60
61 constexpr TBOOL operator!=( const T2Pair<First, Second, Comparator>& other ) const
62 {
63 return !Comparator::IsEqual( first, other.first );
64 }
65
66 constexpr TBOOL operator>( const T2Pair<First, Second, Comparator>& other ) const
67 {
68 return Comparator::IsGreater( first, other.first );
69 }
70
71 constexpr TBOOL operator>=( const T2Pair<First, Second, Comparator>& other ) const
72 {
73 return Comparator::IsGreaterOrEqual( first, other.first );
74 }
75
76 constexpr TBOOL operator<( const T2Pair<First, Second, Comparator>& other ) const
77 {
78 return Comparator::IsLess( first, other.first );
79 }
80
81 constexpr TBOOL operator<=( const T2Pair<First, Second, Comparator>& other ) const
82 {
83 return Comparator::IsLessOrEqual( first, other.first );
84 }
85};
86
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
bool TBOOL
Definition Typedefs.h:6
constexpr T2Pair(First &&a_rFirst, Second &&a_rSecond)
Definition T2Pair.h:37
constexpr T2Pair(const First &a_rcFirst)
Definition T2Pair.h:22
constexpr T2Pair(First &&a_rFirst)
Definition T2Pair.h:27
constexpr Second & GetSecond()
Definition T2Pair.h:43
constexpr T2Pair(const First &a_rcFirst, Second &&a_rSecond)
Definition T2Pair.h:32
constexpr T2Pair & operator=(const T2Pair< First, Second, Comparator > &a_rcOther)
Definition T2Pair.h:45
constexpr T2Pair(const First &a_rcFirst, const Second &a_rcSecond)
Definition T2Pair.h:17
constexpr TBOOL operator!=(const T2Pair< First, Second, Comparator > &other) const
Definition T2Pair.h:61
constexpr TBOOL operator>=(const T2Pair< First, Second, Comparator > &other) const
Definition T2Pair.h:71
constexpr First & GetFirst()
Definition T2Pair.h:42
constexpr TBOOL operator<(const T2Pair< First, Second, Comparator > &other) const
Definition T2Pair.h:76
constexpr TBOOL operator>(const T2Pair< First, Second, Comparator > &other) const
Definition T2Pair.h:66
constexpr TBOOL operator==(const T2Pair< First, Second, Comparator > &other) const
Definition T2Pair.h:56
constexpr TBOOL operator<=(const T2Pair< First, Second, Comparator > &other) const
Definition T2Pair.h:81
constexpr T2Pair()
Definition T2Pair.h:12