31 #ifndef ETL_UTILITY_INCLUDED
32 #define ETL_UTILITY_INCLUDED
38 #if ETL_CPP11_SUPPORTED
50 #if ETL_CPP11_SUPPORTED
53 constexpr
typename etl::remove_reference<T>::type&& move(T&& t) ETL_NOEXCEPT
55 return static_cast<typename etl::remove_reference<T>::type&&
>(t);
60 constexpr T&& forward(
typename etl::remove_reference<T>::type& t) ETL_NOEXCEPT
62 return static_cast<T&&
>(t);
66 constexpr T&& forward(
typename etl::remove_reference<T>::type&& t) ETL_NOEXCEPT
68 return static_cast<T&&
>(t);
74 #if ETL_NOT_USING_STL && !defined(ETL_IN_UNIT_TEST)
77 #if ETL_CPP11_SUPPORTED
79 void swap(T& a, T& b) ETL_NOEXCEPT
87 void swap(T& a, T& b) ETL_NOEXCEPT
95 template<
class T,
size_t N >
96 void swap(T(&a)[N], T(&b)[N]) ETL_NOEXCEPT
98 for (
size_t i = 0; i < N; ++i)
106 template <
typename T1,
typename T2>
109 typedef T1 first_type;
110 typedef T2 second_type;
123 ETL_CONSTEXPR14
pair(
const T1& a,
const T2& b)
129 #if ETL_CPP11_SUPPORTED
131 template <
typename U1,
typename U2>
132 ETL_CONSTEXPR14
pair(U1&& a, U2&& b)
133 : first(
etl::forward<U1>(a))
134 , second(
etl::forward<U2>(b))
140 template <
typename U1,
typename U2>
143 , second(other.second)
150 , second(other.second)
154 #if ETL_CPP11_SUPPORTED
156 template <
typename U1,
typename U2>
158 : first(
etl::forward<U1>(other.first))
159 , second(
etl::forward<U2>(other.second))
164 #if defined(ETL_IN_UNIT_TEST) || ETL_USING_STL
166 template <
typename U1,
typename U2>
167 operator std::pair<U1, U2>()
169 return std::make_pair(first, second);
173 template <
typename U1,
typename U2>
174 pair(
const std::pair<U1, U2>& other)
176 , second(other.second)
180 #if ETL_CPP11_SUPPORTED
182 template <
typename U1,
typename U2>
183 pair(std::pair<U1, U2>&& other)
184 : first(
etl::forward<U1>(other.first))
185 , second(
etl::forward<U2>(other.second))
191 void swap(pair<T1, T2>& other)
193 using ETL_OR_STD::swap;
195 swap(first, other.first);
196 swap(second, other.second);
199 pair<T1, T2>& operator =(
const pair<T1, T2>& other)
202 second = other.second;
207 template <
typename U1,
typename U2>
208 pair<U1, U2>& operator =(
const pair<U1, U2>& other)
211 second = other.second;
216 #if ETL_CPP11_SUPPORTED
217 pair<T1, T2>& operator =(pair<T1, T2>&& other)
219 first = etl::forward<T1>(other.first);
220 second = etl::forward<T2>(other.second);
225 template <
typename U1,
typename U2>
226 pair<U1, U2>& operator =(pair<U1, U2>&& other)
228 first = etl::forward<U1>(other.first);
229 second = etl::forward<U2>(other.second);
237 #if ETL_CPP11_SUPPORTED
238 template <
typename T1,
typename T2>
239 inline pair<T1, T2> make_pair(T1&& a, T2&& b)
241 return pair<T1, T2>(etl::forward<T1>(a), etl::forward<T2>(b));
244 template <
typename T1,
typename T2>
245 inline pair<T1, T2> make_pair(T1 a, T2 b)
247 return pair<T1, T2>(a, b);
252 template <
typename T1,
typename T2>
253 inline void swap(pair<T1, T2>& a, pair<T1, T2>& b)
259 template <
typename T1,
typename T2>
260 inline bool operator ==(
const pair<T1, T2>& a,
const pair<T1, T2>& b)
262 return (a.first == b.first) && (a.second == b.second);
265 template <
typename T1,
typename T2>
266 inline bool operator !=(
const pair<T1, T2>& a,
const pair<T1, T2>& b)
271 template <
typename T1,
typename T2>
272 inline bool operator <(
const pair<T1, T2>& a,
const pair<T1, T2>& b)
274 return (a.first < b.first) ||
275 (!(b.first < a.first) && (a.second < b.second));
278 template <
typename T1,
typename T2>
279 inline bool operator >(
const pair<T1, T2>& a,
const pair<T1, T2>& b)
284 template <
typename T1,
typename T2>
285 inline bool operator <=(
const pair<T1, T2>& a,
const pair<T1, T2>& b)
290 template <
typename T1,
typename T2>
291 inline bool operator >=(
const pair<T1, T2>& a,
const pair<T1, T2>& b)
296 #if ETL_NOT_USING_STL || ETL_CPP14_NOT_SUPPORTED
300 template <
typename T>
303 T old_value = object;
308 template <
typename T,
typename U>
309 T
exchange(T&
object,
const U& new_value)
311 T old_value = object;
319 template <
typename T,
typename U = T>
320 T
exchange(T&
object,
const U& new_value)
322 return std::exchange(
object, new_value);
329 template <
typename T>
337 template <
typename T>
354 return (lhs.x == rhs.x) && (lhs.y == rhs.y);
359 return !(lhs == rhs);
Definition: absolute.h:37
T exchange(T &object, const T &new_value)
exchange (const)
Definition: utility.h:301
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:633
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:645
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:594
etl::add_const< T >::type & as_const(T &t)
as_const
Definition: utility.h:330
void swap(etl::array< T, SIZE > &lhs, etl::array< T, SIZE > &rhs)
Template deduction guides.
Definition: array.h:570
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:582
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:606
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:621
2D coordinate type.
Definition: utility.h:339
Definition: utility.h:108
pair(const std::pair< U1, U2 > &other)
Constructing from std::pair.
Definition: utility.h:174
ETL_CONSTEXPR pair()
Default constructor.
Definition: utility.h:116
pair(const pair< T1, T2 > &other)
Copy constructor.
Definition: utility.h:148