Stroika Library 3.0d20
 
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,
15 const ValueType& value) noexcept (is_nothrow_constructible_v<KEY_TYPE, KEY_TYPE> and
16 is_nothrow_constructible_v<VALUE_TYPE, VALUE_TYPE>)
17 requires (copy_constructible<KEY_TYPE> and copy_constructible<VALUE_TYPE>)
18 : fKey (key)
19 , fValue (value)
20 {
21 // NB: use non-uniform initialization since we allow for conversions of type - constructible_from above
22 }
23 template <typename KEY_TYPE, typename VALUE_TYPE>
24 template <typename KEY_TYPE2, typename VALUE_TYPE2>
25 constexpr KeyValuePair<KEY_TYPE, VALUE_TYPE>::KeyValuePair (const pair<KEY_TYPE2, VALUE_TYPE2>& src)
26 requires (constructible_from<KEY_TYPE, const KEY_TYPE2&> and constructible_from<VALUE_TYPE, const VALUE_TYPE2&>)
27 : fKey (src.first)
28 , fValue (src.second)
29 {
30 // NB: use non-uniform initialization since we allow for conversions of type - constructible_from above
31 }
32 template <typename KEY_TYPE, typename VALUE_TYPE>
33 template <typename KEY_TYPE2, typename VALUE_TYPE2>
34 constexpr KeyValuePair<KEY_TYPE, VALUE_TYPE>::KeyValuePair (const KeyValuePair<KEY_TYPE2, VALUE_TYPE2>& src)
35 requires (constructible_from<KEY_TYPE, const KEY_TYPE2&> and constructible_from<VALUE_TYPE, const VALUE_TYPE2&>)
36 : fKey (src.fKey)
37 , fValue (src.fValue)
38 {
39 // NB: use non-uniform initialization since we allow for conversions of type - constructible_from above
40 }
41 template <typename KEY_TYPE, typename VALUE_TYPE>
42 template <typename KEY_TYPE2, typename VALUE_TYPE2>
43 KeyValuePair<KEY_TYPE, VALUE_TYPE>& KeyValuePair<KEY_TYPE, VALUE_TYPE>::operator= (const pair<KEY_TYPE2, VALUE_TYPE2>& rhs)
44 {
45 fKey = rhs.first;
46 fValue = rhs.second;
47 return *this;
48 }
49 template <typename KEY_TYPE, typename VALUE_TYPE>
50 template <typename KEY_TYPE2, typename VALUE_TYPE2>
51 inline KeyValuePair<KEY_TYPE, VALUE_TYPE>& KeyValuePair<KEY_TYPE, VALUE_TYPE>::operator= (const KeyValuePair<KEY_TYPE2, VALUE_TYPE2>& rhs)
52 {
53 rhs = rhs.fKey;
54 rhs = rhs.fValue;
55 return *this;
56 }
57 template <typename KEY_TYPE, typename VALUE_TYPE>
58 template <typename KEY_TYPE2, typename VALUE_TYPE2>
59 inline KeyValuePair<KEY_TYPE, VALUE_TYPE>& KeyValuePair<KEY_TYPE, VALUE_TYPE>::operator= (pair<KEY_TYPE2, VALUE_TYPE2>&& rhs)
60 {
61 fKey = forward<KEY_TYPE2> (rhs.first);
62 fValue = forward<VALUE_TYPE2> (rhs.second);
63 return *this;
64 }
65 template <typename KEY_TYPE, typename VALUE_TYPE>
66 template <typename KEY_TYPE2, typename VALUE_TYPE2>
67 inline KeyValuePair<KEY_TYPE, VALUE_TYPE>& KeyValuePair<KEY_TYPE, VALUE_TYPE>::operator= (KeyValuePair<KEY_TYPE2, VALUE_TYPE2>&& rhs)
68 {
69 fKey = forward<KEY_TYPE2> (rhs.fKey);
70 fValue = forward<VALUE_TYPE2> (rhs.fValue);
71 return *this;
72 }
73 template <typename KEY_TYPE, typename VALUE_TYPE>
74 constexpr inline auto KeyValuePair<KEY_TYPE, VALUE_TYPE>::operator<=> (const KeyValuePair& rhs) const
75 requires (three_way_comparable<KEY_TYPE> and three_way_comparable<VALUE_TYPE>)
76 {
77 return tie (fKey, fValue) <=> tie (rhs.fKey, rhs.fValue);
78 }
79 template <typename KEY_TYPE, typename VALUE_TYPE>
80 constexpr inline bool KeyValuePair<KEY_TYPE, VALUE_TYPE>::operator== (const KeyValuePair& rhs) const
81 requires (equality_comparable<KEY_TYPE> and equality_comparable<VALUE_TYPE>)
82 {
83 return fKey == rhs.fKey and fValue == rhs.fValue;
84 }
85
86 /*
87 ********************************************************************************
88 *********************** Common::KeyValuePair<KEY_TYPE,void> ********************
89 ********************************************************************************
90 */
91 template <typename KEY_TYPE>
92 constexpr KeyValuePair<KEY_TYPE, void>::KeyValuePair (const KeyType& key)
93 requires (copy_constructible<KEY_TYPE>)
94 : fKey{key}
95 {
96 }
97 template <typename KEY_TYPE>
98 template <typename KEY_TYPE2>
99 constexpr KeyValuePair<KEY_TYPE, void>::KeyValuePair (const pair<KEY_TYPE2, void>& src)
100 requires (constructible_from<KEY_TYPE, const KEY_TYPE2&>)
101 : fKey (src.first)
102 {
103 // NB: use non-uniform initialization since we allow for conversions of type - constructible_from above
104 }
105 template <typename KEY_TYPE>
106 template <typename KEY_TYPE2>
108 requires (constructible_from<KEY_TYPE, const KEY_TYPE2&>)
109 : fKey (src.fKey)
110 {
111 // NB: use non-uniform initialization since we allow for conversions of type - constructible_from above
112 }
113 template <typename KEY_TYPE>
114 template <typename KEY_TYPE2>
115 KeyValuePair<KEY_TYPE, void>& KeyValuePair<KEY_TYPE, void>::operator= (const pair<KEY_TYPE2, void>& rhs)
116 {
117 fKey = rhs.first;
118 return *this;
119 }
120 template <typename KEY_TYPE>
121 template <typename KEY_TYPE2>
122 inline KeyValuePair<KEY_TYPE, void>& KeyValuePair<KEY_TYPE, void>::operator= (const KeyValuePair<KEY_TYPE2, void>& rhs)
123 {
124 rhs = rhs.fKey;
125 return *this;
126 }
127 template <typename KEY_TYPE>
128 template <typename KEY_TYPE2>
129 inline KeyValuePair<KEY_TYPE, void>& KeyValuePair<KEY_TYPE, void>::operator= (pair<KEY_TYPE2, void>&& rhs)
130 {
131 fKey = forward<KEY_TYPE2> (rhs.first);
132 return *this;
133 }
134 template <typename KEY_TYPE>
135 template <typename KEY_TYPE2>
136 inline KeyValuePair<KEY_TYPE, void>& KeyValuePair<KEY_TYPE, void>::operator= (KeyValuePair<KEY_TYPE2, void>&& rhs)
137 {
138 fKey = forward<KEY_TYPE2> (rhs.fKey);
139 return *this;
140 }
141 template <typename KEY_TYPE>
142 constexpr inline auto KeyValuePair<KEY_TYPE, void>::operator<=> (const KeyValuePair& rhs) const
143 requires (three_way_comparable<KEY_TYPE>)
144 {
145 return fKey <=> rhs.fKey;
146 }
147 template <typename KEY_TYPE>
148 constexpr inline bool KeyValuePair<KEY_TYPE, void>::operator== (const KeyValuePair& rhs) const
149 requires (equality_comparable<KEY_TYPE>)
150 {
151 return fKey == rhs.fKey;
152 }
153
154}
constexpr auto operator<=>(const KeyValuePair &) const
constexpr KeyValuePair() noexcept(is_nothrow_constructible_v< KEY_TYPE > and is_nothrow_constructible_v< VALUE_TYPE >)=default
constexpr bool operator==(const KeyValuePair &) const