Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
KeyValuePair.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
5
7
8 /*
9 ********************************************************************************
10 ******************** Common::KeyValuePair<KEY_TYPE,VALUE_TYPE> *****************
11 ********************************************************************************
12 */
13 template <typename KEY_TYPE, typename VALUE_TYPE>
14 constexpr KeyValuePair<KEY_TYPE, VALUE_TYPE>::KeyValuePair (const KeyType& key, const ValueType& value)
15 requires (copy_constructible<KEY_TYPE> and copy_constructible<VALUE_TYPE>)
16 : fKey (key)
17 , fValue (value)
18 {
19 // NB: use non-uniform initialization since we allow for conversions of type - constructible_from above
20 }
21 template <typename KEY_TYPE, typename VALUE_TYPE>
22 template <typename KEY_TYPE2, typename VALUE_TYPE2>
23 constexpr KeyValuePair<KEY_TYPE, VALUE_TYPE>::KeyValuePair (const pair<KEY_TYPE2, VALUE_TYPE2>& src)
24 requires (constructible_from<KEY_TYPE, const KEY_TYPE2&> and constructible_from<VALUE_TYPE, const VALUE_TYPE2&>)
25 : fKey (src.first)
26 , fValue (src.second)
27 {
28 // NB: use non-uniform initialization since we allow for conversions of type - constructible_from above
29 }
30 template <typename KEY_TYPE, typename VALUE_TYPE>
31 template <typename KEY_TYPE2, typename VALUE_TYPE2>
32 constexpr KeyValuePair<KEY_TYPE, VALUE_TYPE>::KeyValuePair (const KeyValuePair<KEY_TYPE2, VALUE_TYPE2>& src)
33 requires (constructible_from<KEY_TYPE, const KEY_TYPE2&> and constructible_from<VALUE_TYPE, const VALUE_TYPE2&>)
34 : fKey (src.fKey)
35 , fValue (src.fValue)
36 {
37 // NB: use non-uniform initialization since we allow for conversions of type - constructible_from above
38 }
39 template <typename KEY_TYPE, typename VALUE_TYPE>
40 template <typename KEY_TYPE2, typename VALUE_TYPE2>
41 KeyValuePair<KEY_TYPE, VALUE_TYPE>& KeyValuePair<KEY_TYPE, VALUE_TYPE>::operator= (const pair<KEY_TYPE2, VALUE_TYPE2>& rhs)
42 {
43 fKey = rhs.first;
44 fValue = rhs.second;
45 return *this;
46 }
47 template <typename KEY_TYPE, typename VALUE_TYPE>
48 template <typename KEY_TYPE2, typename VALUE_TYPE2>
49 inline KeyValuePair<KEY_TYPE, VALUE_TYPE>& KeyValuePair<KEY_TYPE, VALUE_TYPE>::operator= (const KeyValuePair<KEY_TYPE2, VALUE_TYPE2>& rhs)
50 {
51 rhs = rhs.fKey;
52 rhs = rhs.fValue;
53 return *this;
54 }
55 template <typename KEY_TYPE, typename VALUE_TYPE>
56 template <typename KEY_TYPE2, typename VALUE_TYPE2>
57 inline KeyValuePair<KEY_TYPE, VALUE_TYPE>& KeyValuePair<KEY_TYPE, VALUE_TYPE>::operator= (pair<KEY_TYPE2, VALUE_TYPE2>&& rhs)
58 {
59 fKey = forward<KEY_TYPE2> (rhs.first);
60 fValue = forward<VALUE_TYPE2> (rhs.second);
61 return *this;
62 }
63 template <typename KEY_TYPE, typename VALUE_TYPE>
64 template <typename KEY_TYPE2, typename VALUE_TYPE2>
65 inline KeyValuePair<KEY_TYPE, VALUE_TYPE>& KeyValuePair<KEY_TYPE, VALUE_TYPE>::operator= (KeyValuePair<KEY_TYPE2, VALUE_TYPE2>&& rhs)
66 {
67 fKey = forward<KEY_TYPE2> (rhs.fKey);
68 fValue = forward<VALUE_TYPE2> (rhs.fValue);
69 return *this;
70 }
71 template <typename KEY_TYPE, typename VALUE_TYPE>
72 constexpr inline auto KeyValuePair<KEY_TYPE, VALUE_TYPE>::operator<=> (const KeyValuePair& rhs) const
73 requires (three_way_comparable<KEY_TYPE> and three_way_comparable<VALUE_TYPE>)
74 {
75 return tie (fKey, fValue) <=> tie (rhs.fKey, rhs.fValue);
76 }
77 template <typename KEY_TYPE, typename VALUE_TYPE>
78 constexpr inline bool KeyValuePair<KEY_TYPE, VALUE_TYPE>::operator== (const KeyValuePair& rhs) const
79 requires (equality_comparable<KEY_TYPE> and equality_comparable<VALUE_TYPE>)
80 {
81 return fKey == rhs.fKey and fValue == rhs.fValue;
82 }
83
84 /*
85 ********************************************************************************
86 *********************** Common::KeyValuePair<KEY_TYPE,void> ********************
87 ********************************************************************************
88 */
89 template <typename KEY_TYPE>
91 requires (copy_constructible<KEY_TYPE>)
92 : fKey{key}
93 {
94 }
95 template <typename KEY_TYPE>
96 template <typename KEY_TYPE2>
97 constexpr KeyValuePair<KEY_TYPE, void>::KeyValuePair (const pair<KEY_TYPE2, void>& src)
98 requires (constructible_from<KEY_TYPE, const KEY_TYPE2&>)
99 : fKey (src.first)
100 {
101 // NB: use non-uniform initialization since we allow for conversions of type - constructible_from above
102 }
103 template <typename KEY_TYPE>
104 template <typename KEY_TYPE2>
106 requires (constructible_from<KEY_TYPE, const KEY_TYPE2&>)
107 : fKey (src.fKey)
108 {
109 // NB: use non-uniform initialization since we allow for conversions of type - constructible_from above
110 }
111 template <typename KEY_TYPE>
112 template <typename KEY_TYPE2>
113 KeyValuePair<KEY_TYPE, void>& KeyValuePair<KEY_TYPE, void>::operator= (const pair<KEY_TYPE2, void>& rhs)
114 {
115 fKey = rhs.first;
116 return *this;
117 }
118 template <typename KEY_TYPE>
119 template <typename KEY_TYPE2>
120 inline KeyValuePair<KEY_TYPE, void>& KeyValuePair<KEY_TYPE, void>::operator= (const KeyValuePair<KEY_TYPE2, void>& rhs)
121 {
122 rhs = rhs.fKey;
123 return *this;
124 }
125 template <typename KEY_TYPE>
126 template <typename KEY_TYPE2>
127 inline KeyValuePair<KEY_TYPE, void>& KeyValuePair<KEY_TYPE, void>::operator= (pair<KEY_TYPE2, void>&& rhs)
128 {
129 fKey = forward<KEY_TYPE2> (rhs.first);
130 return *this;
131 }
132 template <typename KEY_TYPE>
133 template <typename KEY_TYPE2>
134 inline KeyValuePair<KEY_TYPE, void>& KeyValuePair<KEY_TYPE, void>::operator= (KeyValuePair<KEY_TYPE2, void>&& rhs)
135 {
136 fKey = forward<KEY_TYPE2> (rhs.fKey);
137 return *this;
138 }
139 template <typename KEY_TYPE>
140 constexpr inline auto KeyValuePair<KEY_TYPE, void>::operator<=> (const KeyValuePair& rhs) const
141 requires (three_way_comparable<KEY_TYPE>)
142 {
143 return fKey <=> rhs.fKey;
144 }
145 template <typename KEY_TYPE>
146 constexpr inline bool KeyValuePair<KEY_TYPE, void>::operator== (const KeyValuePair& rhs) const
147 requires (equality_comparable<KEY_TYPE>)
148 {
149 return fKey == rhs.fKey;
150 }
151
152}
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
constexpr auto operator<=>(const KeyValuePair &) const
constexpr bool operator==(const KeyValuePair &) const