From ee82c052c8bb342809c46d11ef48aa6fad4eae1d Mon Sep 17 00:00:00 2001 From: Jonathan Pan Date: Fri, 28 Jun 2019 23:48:42 -0700 Subject: [PATCH] [#133] Making sure comparison operators are in the etl namespace (#135) --- include/etl/deque.h | 150 ++++---- include/etl/fixed_iterator.h | 162 ++++----- include/etl/forward_list.h | 148 ++++---- include/etl/list.h | 146 ++++---- include/etl/map.h | 150 ++++---- include/etl/multimap.h | 150 ++++---- include/etl/multiset.h | 150 ++++---- include/etl/optional.h | 668 +++++++++++++++++------------------ include/etl/set.h | 150 ++++---- 9 files changed, 937 insertions(+), 937 deletions(-) diff --git a/include/etl/deque.h b/include/etl/deque.h index 257bd4b9..d103b319 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -2372,87 +2372,87 @@ namespace etl /// The uninitialised buffer of T used in the deque. typename etl::aligned_storage::value>::type buffer[BUFFER_SIZE]; }; -} -//*************************************************************************** -/// Equal operator. -///\param lhs Reference to the _begin deque. -///\param rhs Reference to the second deque. -///\return true if the arrays are equal, otherwise false -///\ingroup deque -//*************************************************************************** -template -bool operator ==(const etl::ideque& lhs, const etl::ideque& rhs) -{ - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); -} + //*************************************************************************** + /// Equal operator. + ///\param lhs Reference to the _begin deque. + ///\param rhs Reference to the second deque. + ///\return true if the arrays are equal, otherwise false + ///\ingroup deque + //*************************************************************************** + template + bool operator ==(const etl::ideque& lhs, const etl::ideque& rhs) + { + return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + } -//*************************************************************************** -/// Not equal operator. -///\param lhs Reference to the _begin deque. -///\param rhs Reference to the second deque. -///\return true if the arrays are not equal, otherwise false -///\ingroup deque -//*************************************************************************** -template -bool operator !=(const etl::ideque& lhs, const etl::ideque& rhs) -{ - return !(lhs == rhs); -} + //*************************************************************************** + /// Not equal operator. + ///\param lhs Reference to the _begin deque. + ///\param rhs Reference to the second deque. + ///\return true if the arrays are not equal, otherwise false + ///\ingroup deque + //*************************************************************************** + template + bool operator !=(const etl::ideque& lhs, const etl::ideque& rhs) + { + return !(lhs == rhs); + } -//*************************************************************************** -/// Less than operator. -///\param lhs Reference to the _begin deque. -///\param rhs Reference to the second deque. -///\return true if the _begin deque is lexicographically less than the second, otherwise false -///\ingroup deque -//*************************************************************************** -template -bool operator <(const etl::ideque& lhs, const etl::ideque& rhs) -{ - return std::lexicographical_compare(lhs.begin(), - lhs.end(), - rhs.begin(), - rhs.end()); -} + //*************************************************************************** + /// Less than operator. + ///\param lhs Reference to the _begin deque. + ///\param rhs Reference to the second deque. + ///\return true if the _begin deque is lexicographically less than the second, otherwise false + ///\ingroup deque + //*************************************************************************** + template + bool operator <(const etl::ideque& lhs, const etl::ideque& rhs) + { + return std::lexicographical_compare(lhs.begin(), + lhs.end(), + rhs.begin(), + rhs.end()); + } -//*************************************************************************** -/// Less than or equal operator. -///\param lhs Reference to the _begin deque. -///\param rhs Reference to the second deque. -///\return true if the _begin deque is lexicographically less than or equal to the second, otherwise false -///\ingroup deque -//*************************************************************************** -template -bool operator <=(const etl::ideque& lhs, const etl::ideque& rhs) -{ - return !(lhs > rhs); -} + //*************************************************************************** + /// Less than or equal operator. + ///\param lhs Reference to the _begin deque. + ///\param rhs Reference to the second deque. + ///\return true if the _begin deque is lexicographically less than or equal to the second, otherwise false + ///\ingroup deque + //*************************************************************************** + template + bool operator <=(const etl::ideque& lhs, const etl::ideque& rhs) + { + return !(lhs > rhs); + } -//*************************************************************************** -/// Greater than operator. -///\param lhs Reference to the _begin deque. -///\param rhs Reference to the second deque. -///\return true if the _begin deque is lexicographically greater than the second, otherwise false -///\ingroup deque -//*************************************************************************** -template -bool operator >(const etl::ideque& lhs, const etl::ideque& rhs) -{ - return (rhs < lhs); -} + //*************************************************************************** + /// Greater than operator. + ///\param lhs Reference to the _begin deque. + ///\param rhs Reference to the second deque. + ///\return true if the _begin deque is lexicographically greater than the second, otherwise false + ///\ingroup deque + //*************************************************************************** + template + bool operator >(const etl::ideque& lhs, const etl::ideque& rhs) + { + return (rhs < lhs); + } -//*************************************************************************** -/// Greater than or equal operator. -///\param "lhs Reference to the _begin deque. -///\param "rhs Reference to the second deque. -///\return true if the _begin deque is lexicographically greater than or equal to the second, otherwise false -///\ingroup deque -//*************************************************************************** -template -bool operator >=(const etl::ideque& lhs, const etl::ideque& rhs) -{ - return !(lhs < rhs); + //*************************************************************************** + /// Greater than or equal operator. + ///\param "lhs Reference to the _begin deque. + ///\param "rhs Reference to the second deque. + ///\return true if the _begin deque is lexicographically greater than or equal to the second, otherwise false + ///\ingroup deque + //*************************************************************************** + template + bool operator >=(const etl::ideque& lhs, const etl::ideque& rhs) + { + return !(lhs < rhs); + } } #undef ETL_FILE diff --git a/include/etl/fixed_iterator.h b/include/etl/fixed_iterator.h index e756b734..15accbb1 100644 --- a/include/etl/fixed_iterator.h +++ b/include/etl/fixed_iterator.h @@ -174,97 +174,97 @@ namespace etl TIterator it; ///< The underlying iterator. }; -} -//***************************************************************************** -/// + difference operator. -//***************************************************************************** -template -etl::fixed_iterator& operator +(etl::fixed_iterator& lhs, - typename std::iterator_traits::difference_type /*rhs*/) -{ - return lhs; -} + //***************************************************************************** + /// + difference operator. + //***************************************************************************** + template + etl::fixed_iterator& operator +(etl::fixed_iterator& lhs, + typename std::iterator_traits::difference_type /*rhs*/) + { + return lhs; + } -//***************************************************************************** -/// - difference operator. -//***************************************************************************** -template -etl::fixed_iterator& operator -(etl::fixed_iterator& lhs, - typename std::iterator_traits::difference_type /*rhs*/) -{ - return lhs; -} + //***************************************************************************** + /// - difference operator. + //***************************************************************************** + template + etl::fixed_iterator& operator -(etl::fixed_iterator& lhs, + typename std::iterator_traits::difference_type /*rhs*/) + { + return lhs; + } -//***************************************************************************** -/// - fixed_iterator operator. -//***************************************************************************** -template -typename std::iterator_traits::difference_type operator -(etl::fixed_iterator& lhs, - etl::fixed_iterator& rhs) -{ - return TIterator(lhs) - TIterator(rhs); -} + //***************************************************************************** + /// - fixed_iterator operator. + //***************************************************************************** + template + typename std::iterator_traits::difference_type operator -(etl::fixed_iterator& lhs, + etl::fixed_iterator& rhs) + { + return TIterator(lhs) - TIterator(rhs); + } -//***************************************************************************** -/// Equality operator. fixed_iterator == fixed_iterator. -//***************************************************************************** -template -bool operator ==(const etl::fixed_iterator& lhs, - const etl::fixed_iterator& rhs) -{ - return TIterator(lhs) == TIterator(rhs); -} + //***************************************************************************** + /// Equality operator. fixed_iterator == fixed_iterator. + //***************************************************************************** + template + bool operator ==(const etl::fixed_iterator& lhs, + const etl::fixed_iterator& rhs) + { + return TIterator(lhs) == TIterator(rhs); + } -//***************************************************************************** -/// Equality operator. fixed_iterator == iterator. -//***************************************************************************** -template -bool operator ==(const etl::fixed_iterator& lhs, - TIterator rhs) -{ - return TIterator(lhs) == rhs; -} + //***************************************************************************** + /// Equality operator. fixed_iterator == iterator. + //***************************************************************************** + template + bool operator ==(const etl::fixed_iterator& lhs, + TIterator rhs) + { + return TIterator(lhs) == rhs; + } -//***************************************************************************** -/// Equality operator. iterator == fixed_iterator. -//***************************************************************************** -template -bool operator ==(TIterator lhs, - const etl::fixed_iterator& rhs) -{ - return lhs == TIterator(rhs); -} + //***************************************************************************** + /// Equality operator. iterator == fixed_iterator. + //***************************************************************************** + template + bool operator ==(TIterator lhs, + const etl::fixed_iterator& rhs) + { + return lhs == TIterator(rhs); + } -//***************************************************************************** -/// Inequality operator. fixed_iterator == fixed_iterator. -//***************************************************************************** -template -bool operator !=(const etl::fixed_iterator& lhs, - const etl::fixed_iterator& rhs) -{ - return !(lhs == rhs); -} + //***************************************************************************** + /// Inequality operator. fixed_iterator == fixed_iterator. + //***************************************************************************** + template + bool operator !=(const etl::fixed_iterator& lhs, + const etl::fixed_iterator& rhs) + { + return !(lhs == rhs); + } -//***************************************************************************** -/// Inequality operator. fixed_iterator == iterator. -//***************************************************************************** -template -bool operator !=(const etl::fixed_iterator& lhs, - TIterator rhs) -{ - return !(lhs == rhs); -} + //***************************************************************************** + /// Inequality operator. fixed_iterator == iterator. + //***************************************************************************** + template + bool operator !=(const etl::fixed_iterator& lhs, + TIterator rhs) + { + return !(lhs == rhs); + } -//***************************************************************************** -/// Inequality operator. iterator == fixed_iterator. -//***************************************************************************** -template -bool operator !=(TIterator& lhs, - const etl::fixed_iterator& rhs) -{ - return !(lhs == rhs); + //***************************************************************************** + /// Inequality operator. iterator == fixed_iterator. + //***************************************************************************** + template + bool operator !=(TIterator& lhs, + const etl::fixed_iterator& rhs) + { + return !(lhs == rhs); + } } #endif diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index 5fe0a1c3..64334022 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -1825,86 +1825,86 @@ namespace etl this->set_node_pool(pool); } }; -} -//************************************************************************* -/// Equal operator. -///\param lhs Reference to the first forward_list. -///\param rhs Reference to the second forward_list. -///\return true if the arrays are equal, otherwise false. -//************************************************************************* -template -bool operator ==(const etl::iforward_list& lhs, const etl::iforward_list& rhs) -{ - return (lhs.size() == rhs.size()) && - std::equal(lhs.begin(), lhs.end(), rhs.begin()); -} + //************************************************************************* + /// Equal operator. + ///\param lhs Reference to the first forward_list. + ///\param rhs Reference to the second forward_list. + ///\return true if the arrays are equal, otherwise false. + //************************************************************************* + template + bool operator ==(const etl::iforward_list& lhs, const etl::iforward_list& rhs) + { + return (lhs.size() == rhs.size()) && + std::equal(lhs.begin(), lhs.end(), rhs.begin()); + } -//************************************************************************* -/// Not equal operator. -///\param lhs Reference to the first forward_list. -///\param rhs Reference to the second forward_list. -///\return true if the arrays are not equal, otherwise false. -//************************************************************************* -template -bool operator !=(const etl::iforward_list& lhs, const etl::iforward_list& rhs) -{ - return !(lhs == rhs); -} + //************************************************************************* + /// Not equal operator. + ///\param lhs Reference to the first forward_list. + ///\param rhs Reference to the second forward_list. + ///\return true if the arrays are not equal, otherwise false. + //************************************************************************* + template + bool operator !=(const etl::iforward_list& lhs, const etl::iforward_list& rhs) + { + return !(lhs == rhs); + } -//************************************************************************* -/// Less than operator. -///\param lhs Reference to the first forward_list. -///\param rhs Reference to the second forward_list. -///\return true if the first forward_list is lexicographically less than the -/// second, otherwise false. -//************************************************************************* -template -bool operator <(const etl::iforward_list& lhs, const etl::iforward_list& rhs) -{ - return std::lexicographical_compare(lhs.begin(), - lhs.end(), - rhs.begin(), - rhs.end()); -} + //************************************************************************* + /// Less than operator. + ///\param lhs Reference to the first forward_list. + ///\param rhs Reference to the second forward_list. + ///\return true if the first forward_list is lexicographically less than the + /// second, otherwise false. + //************************************************************************* + template + bool operator <(const etl::iforward_list& lhs, const etl::iforward_list& rhs) + { + return std::lexicographical_compare(lhs.begin(), + lhs.end(), + rhs.begin(), + rhs.end()); + } -//************************************************************************* -/// Greater than operator. -///\param lhs Reference to the first forward_list. -///\param rhs Reference to the second forward_list. -///\return true if the first forward_list is lexicographically greater than the -/// second, otherwise false. -//************************************************************************* -template -bool operator >(const etl::iforward_list& lhs, const etl::iforward_list& rhs) -{ - return (rhs < lhs); -} + //************************************************************************* + /// Greater than operator. + ///\param lhs Reference to the first forward_list. + ///\param rhs Reference to the second forward_list. + ///\return true if the first forward_list is lexicographically greater than the + /// second, otherwise false. + //************************************************************************* + template + bool operator >(const etl::iforward_list& lhs, const etl::iforward_list& rhs) + { + return (rhs < lhs); + } -//************************************************************************* -/// Less than or equal operator. -///\param lhs Reference to the first forward_list. -///\param rhs Reference to the second forward_list. -///\return true if the first forward_list is lexicographically less than or equal -/// to the second, otherwise false. -//************************************************************************* -template -bool operator <=(const etl::iforward_list& lhs, const etl::iforward_list& rhs) -{ - return !(lhs > rhs); -} + //************************************************************************* + /// Less than or equal operator. + ///\param lhs Reference to the first forward_list. + ///\param rhs Reference to the second forward_list. + ///\return true if the first forward_list is lexicographically less than or equal + /// to the second, otherwise false. + //************************************************************************* + template + bool operator <=(const etl::iforward_list& lhs, const etl::iforward_list& rhs) + { + return !(lhs > rhs); + } -//************************************************************************* -/// Greater than or equal operator. -///\param lhs Reference to the first forward_list. -///\param rhs Reference to the second forward_list. -///\return true if the first forward_list is lexicographically greater than or -/// equal to the second, otherwise false. -//************************************************************************* -template -bool operator >=(const etl::iforward_list& lhs, const etl::iforward_list& rhs) -{ - return !(lhs < rhs); + //************************************************************************* + /// Greater than or equal operator. + ///\param lhs Reference to the first forward_list. + ///\param rhs Reference to the second forward_list. + ///\return true if the first forward_list is lexicographically greater than or + /// equal to the second, otherwise false. + //************************************************************************* + template + bool operator >=(const etl::iforward_list& lhs, const etl::iforward_list& rhs) + { + return !(lhs < rhs); + } } #include "private/minmax_pop.h" diff --git a/include/etl/list.h b/include/etl/list.h index 727897c0..aa9f0235 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -2246,85 +2246,85 @@ namespace etl this->set_node_pool(pool); } }; -} -//************************************************************************* -/// Equal operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the arrays are equal, otherwise false. -//************************************************************************* -template -bool operator ==(const etl::ilist& lhs, const etl::ilist& rhs) -{ - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); -} + //************************************************************************* + /// Equal operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the arrays are equal, otherwise false. + //************************************************************************* + template + bool operator ==(const etl::ilist& lhs, const etl::ilist& rhs) + { + return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + } -//************************************************************************* -/// Not equal operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the arrays are not equal, otherwise false. -//************************************************************************* -template -bool operator !=(const etl::ilist& lhs, const etl::ilist& rhs) -{ - return !(lhs == rhs); -} + //************************************************************************* + /// Not equal operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the arrays are not equal, otherwise false. + //************************************************************************* + template + bool operator !=(const etl::ilist& lhs, const etl::ilist& rhs) + { + return !(lhs == rhs); + } -//************************************************************************* -/// Less than operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically less than the -/// second, otherwise false. -//************************************************************************* -template -bool operator <(const etl::ilist& lhs, const etl::ilist& rhs) -{ - return std::lexicographical_compare(lhs.begin(), - lhs.end(), - rhs.begin(), - rhs.end()); -} + //************************************************************************* + /// Less than operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically less than the + /// second, otherwise false. + //************************************************************************* + template + bool operator <(const etl::ilist& lhs, const etl::ilist& rhs) + { + return std::lexicographical_compare(lhs.begin(), + lhs.end(), + rhs.begin(), + rhs.end()); + } -//************************************************************************* -/// Greater than operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically greater than the -/// second, otherwise false. -//************************************************************************* -template -bool operator >(const etl::ilist& lhs, const etl::ilist& rhs) -{ - return (rhs < lhs); -} + //************************************************************************* + /// Greater than operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically greater than the + /// second, otherwise false. + //************************************************************************* + template + bool operator >(const etl::ilist& lhs, const etl::ilist& rhs) + { + return (rhs < lhs); + } -//************************************************************************* -/// Less than or equal operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically less than or equal -/// to the second, otherwise false. -//************************************************************************* -template -bool operator <=(const etl::ilist& lhs, const etl::ilist& rhs) -{ - return !(lhs > rhs); -} + //************************************************************************* + /// Less than or equal operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically less than or equal + /// to the second, otherwise false. + //************************************************************************* + template + bool operator <=(const etl::ilist& lhs, const etl::ilist& rhs) + { + return !(lhs > rhs); + } -//************************************************************************* -/// Greater than or equal operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically greater than or -/// equal to the second, otherwise false. -//************************************************************************* -template -bool operator >=(const etl::ilist& lhs, const etl::ilist& rhs) -{ - return !(lhs < rhs); + //************************************************************************* + /// Greater than or equal operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically greater than or + /// equal to the second, otherwise false. + //************************************************************************* + template + bool operator >=(const etl::ilist& lhs, const etl::ilist& rhs) + { + return !(lhs < rhs); + } } #include "private/minmax_pop.h" diff --git a/include/etl/map.h b/include/etl/map.h index 9b35c708..b33dc199 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -2115,87 +2115,87 @@ namespace etl /// The pool of data nodes used for the map. etl::pool::Data_Node, MAX_SIZE> node_pool; }; -} -//*************************************************************************** -/// Equal operator. -///\param lhs Reference to the first lookup. -///\param rhs Reference to the second lookup. -///\return true if the arrays are equal, otherwise false -///\ingroup lookup -//*************************************************************************** -template -bool operator ==(const etl::imap& lhs, const etl::imap& rhs) -{ - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); -} + //*************************************************************************** + /// Equal operator. + ///\param lhs Reference to the first lookup. + ///\param rhs Reference to the second lookup. + ///\return true if the arrays are equal, otherwise false + ///\ingroup lookup + //*************************************************************************** + template + bool operator ==(const etl::imap& lhs, const etl::imap& rhs) + { + return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + } -//*************************************************************************** -/// Not equal operator. -///\param lhs Reference to the first lookup. -///\param rhs Reference to the second lookup. -///\return true if the arrays are not equal, otherwise false -///\ingroup lookup -//*************************************************************************** -template -bool operator !=(const etl::imap& lhs, const etl::imap& rhs) -{ - return !(lhs == rhs); -} + //*************************************************************************** + /// Not equal operator. + ///\param lhs Reference to the first lookup. + ///\param rhs Reference to the second lookup. + ///\return true if the arrays are not equal, otherwise false + ///\ingroup lookup + //*************************************************************************** + template + bool operator !=(const etl::imap& lhs, const etl::imap& rhs) + { + return !(lhs == rhs); + } -//************************************************************************* -/// Less than operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically less than the -/// second, otherwise false. -//************************************************************************* -template -bool operator <(const etl::imap& lhs, const etl::imap& rhs) -{ - return std::lexicographical_compare(lhs.begin(), - lhs.end(), - rhs.begin(), - rhs.end()); -} + //************************************************************************* + /// Less than operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically less than the + /// second, otherwise false. + //************************************************************************* + template + bool operator <(const etl::imap& lhs, const etl::imap& rhs) + { + return std::lexicographical_compare(lhs.begin(), + lhs.end(), + rhs.begin(), + rhs.end()); + } -//************************************************************************* -/// Greater than operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically greater than the -/// second, otherwise false. -//************************************************************************* -template -bool operator >(const etl::imap& lhs, const etl::imap& rhs) -{ - return (rhs < lhs); -} + //************************************************************************* + /// Greater than operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically greater than the + /// second, otherwise false. + //************************************************************************* + template + bool operator >(const etl::imap& lhs, const etl::imap& rhs) + { + return (rhs < lhs); + } -//************************************************************************* -/// Less than or equal operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically less than or equal -/// to the second, otherwise false. -//************************************************************************* -template -bool operator <=(const etl::imap& lhs, const etl::imap& rhs) -{ - return !(lhs > rhs); -} + //************************************************************************* + /// Less than or equal operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically less than or equal + /// to the second, otherwise false. + //************************************************************************* + template + bool operator <=(const etl::imap& lhs, const etl::imap& rhs) + { + return !(lhs > rhs); + } -//************************************************************************* -/// Greater than or equal operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically greater than or -/// equal to the second, otherwise false. -//************************************************************************* -template -bool operator >=(const etl::imap& lhs, const etl::imap& rhs) -{ - return !(lhs < rhs); + //************************************************************************* + /// Greater than or equal operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically greater than or + /// equal to the second, otherwise false. + //************************************************************************* + template + bool operator >=(const etl::imap& lhs, const etl::imap& rhs) + { + return !(lhs < rhs); + } } #include "private/minmax_pop.h" diff --git a/include/etl/multimap.h b/include/etl/multimap.h index df256275..c74a4fcf 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -2001,87 +2001,87 @@ namespace etl /// The pool of data nodes used for the multimap. etl::pool::Data_Node, MAX_SIZE> node_pool; }; -} -//*************************************************************************** -/// Equal operator. -///\param lhs Reference to the first lookup. -///\param rhs Reference to the second lookup. -///\return true if the arrays are equal, otherwise false -///\ingroup lookup -//*************************************************************************** -template -bool operator ==(const etl::imultimap& lhs, const etl::imultimap& rhs) -{ - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); -} + //*************************************************************************** + /// Equal operator. + ///\param lhs Reference to the first lookup. + ///\param rhs Reference to the second lookup. + ///\return true if the arrays are equal, otherwise false + ///\ingroup lookup + //*************************************************************************** + template + bool operator ==(const etl::imultimap& lhs, const etl::imultimap& rhs) + { + return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + } -//*************************************************************************** -/// Not equal operator. -///\param lhs Reference to the first lookup. -///\param rhs Reference to the second lookup. -///\return true if the arrays are not equal, otherwise false -///\ingroup lookup -//*************************************************************************** -template -bool operator !=(const etl::imultimap& lhs, const etl::imultimap& rhs) -{ - return !(lhs == rhs); -} + //*************************************************************************** + /// Not equal operator. + ///\param lhs Reference to the first lookup. + ///\param rhs Reference to the second lookup. + ///\return true if the arrays are not equal, otherwise false + ///\ingroup lookup + //*************************************************************************** + template + bool operator !=(const etl::imultimap& lhs, const etl::imultimap& rhs) + { + return !(lhs == rhs); + } -//************************************************************************* -/// Less than operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically less than the -/// second, otherwise false. -//************************************************************************* -template -bool operator <(const etl::imultimap& lhs, const etl::imultimap& rhs) -{ - return std::lexicographical_compare(lhs.begin(), - lhs.end(), - rhs.begin(), - rhs.end()); -} + //************************************************************************* + /// Less than operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically less than the + /// second, otherwise false. + //************************************************************************* + template + bool operator <(const etl::imultimap& lhs, const etl::imultimap& rhs) + { + return std::lexicographical_compare(lhs.begin(), + lhs.end(), + rhs.begin(), + rhs.end()); + } -//************************************************************************* -/// Greater than operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically greater than the -/// second, otherwise false. -//************************************************************************* -template -bool operator >(const etl::imultimap& lhs, const etl::imultimap& rhs) -{ - return (rhs < lhs); -} + //************************************************************************* + /// Greater than operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically greater than the + /// second, otherwise false. + //************************************************************************* + template + bool operator >(const etl::imultimap& lhs, const etl::imultimap& rhs) + { + return (rhs < lhs); + } -//************************************************************************* -/// Less than or equal operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically less than or equal -/// to the second, otherwise false. -//************************************************************************* -template -bool operator <=(const etl::imultimap& lhs, const etl::imultimap& rhs) -{ - return !(lhs > rhs); -} + //************************************************************************* + /// Less than or equal operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically less than or equal + /// to the second, otherwise false. + //************************************************************************* + template + bool operator <=(const etl::imultimap& lhs, const etl::imultimap& rhs) + { + return !(lhs > rhs); + } -//************************************************************************* -/// Greater than or equal operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically greater than or -/// equal to the second, otherwise false. -//************************************************************************* -template -bool operator >=(const etl::imultimap& lhs, const etl::imultimap& rhs) -{ - return !(lhs < rhs); + //************************************************************************* + /// Greater than or equal operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically greater than or + /// equal to the second, otherwise false. + //************************************************************************* + template + bool operator >=(const etl::imultimap& lhs, const etl::imultimap& rhs) + { + return !(lhs < rhs); + } } #include "private/minmax_pop.h" diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 995f6ea0..018fbe35 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -1966,87 +1966,87 @@ namespace etl /// The pool of data nodes used for the multiset. etl::pool::Data_Node, MAX_SIZE> node_pool; }; -} -//*************************************************************************** -/// Equal operator. -///\param lhs Reference to the first lookup. -///\param rhs Reference to the second lookup. -///\return true if the arrays are equal, otherwise false -///\ingroup lookup -//*************************************************************************** -template -bool operator ==(const etl::imultiset& lhs, const etl::imultiset& rhs) -{ - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); -} + //*************************************************************************** + /// Equal operator. + ///\param lhs Reference to the first lookup. + ///\param rhs Reference to the second lookup. + ///\return true if the arrays are equal, otherwise false + ///\ingroup lookup + //*************************************************************************** + template + bool operator ==(const etl::imultiset& lhs, const etl::imultiset& rhs) + { + return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + } -//*************************************************************************** -/// Not equal operator. -///\param lhs Reference to the first lookup. -///\param rhs Reference to the second lookup. -///\return true if the arrays are not equal, otherwise false -///\ingroup lookup -//*************************************************************************** -template -bool operator !=(const etl::imultiset& lhs, const etl::imultiset& rhs) -{ - return !(lhs == rhs); -} + //*************************************************************************** + /// Not equal operator. + ///\param lhs Reference to the first lookup. + ///\param rhs Reference to the second lookup. + ///\return true if the arrays are not equal, otherwise false + ///\ingroup lookup + //*************************************************************************** + template + bool operator !=(const etl::imultiset& lhs, const etl::imultiset& rhs) + { + return !(lhs == rhs); + } -//************************************************************************* -/// Less than operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically less than the -/// second, otherwise false. -//************************************************************************* -template -bool operator <(const etl::imultiset& lhs, const etl::imultiset& rhs) -{ - return std::lexicographical_compare(lhs.begin(), - lhs.end(), - rhs.begin(), - rhs.end()); -} + //************************************************************************* + /// Less than operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically less than the + /// second, otherwise false. + //************************************************************************* + template + bool operator <(const etl::imultiset& lhs, const etl::imultiset& rhs) + { + return std::lexicographical_compare(lhs.begin(), + lhs.end(), + rhs.begin(), + rhs.end()); + } -//************************************************************************* -/// Greater than operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically greater than the -/// second, otherwise false. -//************************************************************************* -template -bool operator >(const etl::imultiset& lhs, const etl::imultiset& rhs) -{ - return (rhs < lhs); -} + //************************************************************************* + /// Greater than operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically greater than the + /// second, otherwise false. + //************************************************************************* + template + bool operator >(const etl::imultiset& lhs, const etl::imultiset& rhs) + { + return (rhs < lhs); + } -//************************************************************************* -/// Less than or equal operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically less than or equal -/// to the second, otherwise false. -//************************************************************************* -template -bool operator <=(const etl::imultiset& lhs, const etl::imultiset& rhs) -{ - return !(lhs > rhs); -} + //************************************************************************* + /// Less than or equal operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically less than or equal + /// to the second, otherwise false. + //************************************************************************* + template + bool operator <=(const etl::imultiset& lhs, const etl::imultiset& rhs) + { + return !(lhs > rhs); + } -//************************************************************************* -/// Greater than or equal operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically greater than or -/// equal to the second, otherwise false. -//************************************************************************* -template -bool operator >=(const etl::imultiset& lhs, const etl::imultiset& rhs) -{ - return !(lhs < rhs); + //************************************************************************* + /// Greater than or equal operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically greater than or + /// equal to the second, otherwise false. + //************************************************************************* + template + bool operator >=(const etl::imultiset& lhs, const etl::imultiset& rhs) + { + return !(lhs < rhs); + } } #include "private/minmax_pop.h" diff --git a/include/etl/optional.h b/include/etl/optional.h index 3c3d44b7..8c7777ff 100644 --- a/include/etl/optional.h +++ b/include/etl/optional.h @@ -419,6 +419,340 @@ namespace etl typename etl::aligned_storage_as::type storage; bool valid; }; + + //*************************************************************************** + /// Equality operator. cppreference 1 + //*************************************************************************** + template + bool operator ==(const etl::optional& lhs, const etl::optional& rhs) + { + if (bool(lhs) != bool(rhs)) + { + return false; + } + else if (!bool(lhs) && !bool(rhs)) + { + return true; + } + else + { + return lhs.value() == rhs.value(); + } + } + + //*************************************************************************** + /// Equality operator. cppreference 2 + //*************************************************************************** + template + bool operator !=(const etl::optional& lhs, const etl::optional& rhs) + { + return !(lhs == rhs); + } + + //*************************************************************************** + /// Less than operator. cppreference 3 + //*************************************************************************** + template + bool operator <(const etl::optional& lhs, const etl::optional& rhs) + { + if (!bool(rhs)) + { + return false; + } + else if (!bool(lhs)) + { + return true; + } + else + { + return lhs.value() < rhs.value(); + } + } + + //*************************************************************************** + /// Less than equal operator. cppreference 4 + //*************************************************************************** + template + bool operator <=(const etl::optional& lhs, const etl::optional& rhs) + { + if (!bool(lhs)) + { + return true; + } + else if (!bool(rhs)) + { + return false; + } + else + { + return lhs.value() <= rhs.value(); + } + } + + //*************************************************************************** + /// greater than operator. cppreference 5 + //*************************************************************************** + template + bool operator >(const etl::optional& lhs, const etl::optional& rhs) + { + if (!bool(lhs)) + { + return false; + } + else if (!bool(rhs)) + { + return true; + } + else + { + return lhs.value() > rhs.value(); + } + } + + //*************************************************************************** + /// greater than equal operator. cppreference 6 + //*************************************************************************** + template + bool operator >=(const etl::optional& lhs, const etl::optional& rhs) + { + if (!bool(rhs)) + { + return true; + } + else if (!bool(lhs)) + { + return false; + } + else + { + return lhs.value() >= rhs.value(); + } + } + + //*************************************************************************** + /// Equality operator. cppreference 7 + //*************************************************************************** + template + bool operator ==(const etl::optional& lhs, etl::nullopt_t) + { + return !bool(lhs); + } + + //*************************************************************************** + /// Equality operator. cppreference 8 + //*************************************************************************** + template + bool operator ==(etl::nullopt_t, const etl::optional& rhs) + { + return !bool(rhs); + } + + //*************************************************************************** + /// Inequality operator. cppreference 9 + //*************************************************************************** + template + bool operator !=(const etl::optional& lhs, etl::nullopt_t) + { + return !(lhs == etl::nullopt); + } + + //*************************************************************************** + /// Inequality operator. cppreference 10 + //*************************************************************************** + template + bool operator !=(etl::nullopt_t , const etl::optional& rhs) + { + return !(etl::nullopt == rhs); + } + + //*************************************************************************** + /// Less than operator. cppreference 11 + //*************************************************************************** + template + bool operator <(const etl::optional&, etl::nullopt_t) + { + return false; + } + + //*************************************************************************** + /// Less than operator. cppreference 12 + //*************************************************************************** + template + bool operator <(etl::nullopt_t, const etl::optional& rhs) + { + return bool(rhs); + } + + //*************************************************************************** + /// Less than equal operator. cppreference 13 + //*************************************************************************** + template + bool operator <=(const etl::optional& lhs, etl::nullopt_t) + { + return !bool(lhs); + } + + //*************************************************************************** + /// Less than equal operator. cppreference 14 + //*************************************************************************** + template + bool operator <=(etl::nullopt_t, const etl::optional&) + { + return true; + } + + //*************************************************************************** + /// Greater than operator. cppreference 15 + //*************************************************************************** + template + bool operator >(const etl::optional& lhs, etl::nullopt_t) + { + return bool(lhs); + } + + //*************************************************************************** + /// Greater than operator. cppreference 16 + //*************************************************************************** + template + bool operator >(etl::nullopt_t, const etl::optional&) + { + return false; + } + + //*************************************************************************** + /// Greater than equal operator. cppreference 17 + //*************************************************************************** + template + bool operator >=(const etl::optional&, etl::nullopt_t) + { + return true; + } + + //*************************************************************************** + /// Greater than equal operator. cppreference 18 + //*************************************************************************** + template + bool operator >=(etl::nullopt_t, const etl::optional& rhs) + { + return !bool(rhs); + } + + //*************************************************************************** + /// Equality operator. cppreference 19 + //************************************************************************** + template + bool operator ==(const etl::optional& lhs, const U& rhs) + { + return bool(lhs) ? lhs.value() == rhs : false; + } + + //*************************************************************************** + /// Inequality operator. cppreference 21 + //************************************************************************** + template + bool operator !=(const etl::optional& lhs, const U& rhs) + { + return !(lhs == rhs); + } + + //*************************************************************************** + /// Equality operator. cppreference 20 + //************************************************************************** + template + bool operator ==(const U& lhs, const etl::optional& rhs) + { + return bool(rhs) ? rhs.value() == lhs : false; + } + + //*************************************************************************** + /// Inequality operator. cppreference 22 + //************************************************************************** + template + bool operator !=(const U& lhs, const etl::optional& rhs) + { + return !(lhs == rhs); + } + + //*************************************************************************** + /// Less than operator. cppreference 23 + //*************************************************************************** + template + bool operator <(const etl::optional& lhs, const U& rhs) + { + return bool(lhs) ? lhs.value() < rhs : true; + } + + //*************************************************************************** + /// Less than operator. cppreference 24 + //*************************************************************************** + template + bool operator <(const U& lhs, const etl::optional& rhs) + { + return bool(rhs) ? lhs < rhs.value() : false; + } + + //*************************************************************************** + /// Less than equal operator. cppreference 25 + //*************************************************************************** + template + bool operator <=(const etl::optional& lhs, const U& rhs) + { + return bool(lhs) ? lhs.value() <= rhs : true; + } + + //*************************************************************************** + /// Less than equal operator. cppreference 26 + //*************************************************************************** + template + bool operator <=(const U& lhs, const etl::optional& rhs) + { + return bool(rhs) ? lhs <= rhs.value() : false; + } + + //*************************************************************************** + /// Greater than operator. cppreference 27 + //*************************************************************************** + template + bool operator >(const etl::optional& lhs, const U& rhs) + { + return bool(lhs) ? lhs.value() > rhs : false; + } + + //*************************************************************************** + /// Greater than operator. cppreference 28 + //*************************************************************************** + template + bool operator >(const U& lhs, const etl::optional& rhs) + { + return bool(rhs) ? lhs > rhs.value() : true; + } + + //*************************************************************************** + /// Greater than equal operator. cppreference 29 + //*************************************************************************** + template + bool operator >=(const etl::optional& lhs, const U& rhs) + { + return bool(lhs) ? lhs.value() >= rhs : false; + } + + //*************************************************************************** + /// Greater than equal operator. cppreference 30 + //*************************************************************************** + template + bool operator >=(const U& lhs, const etl::optional& rhs) + { + return bool(rhs) ? lhs >= rhs.value() : true; + } + + //*************************************************************************** + /// Make an optional. + //*************************************************************************** + template + etl::optional::type> make_optional(T& value) + { + return etl::optional::type>(value); + } } //************************************************************************* @@ -430,338 +764,4 @@ void swap(etl::optional& lhs, etl::optional& rhs) lhs.swap(rhs); } -//*************************************************************************** -/// Equality operator. cppreference 1 -//*************************************************************************** -template -bool operator ==(const etl::optional& lhs, const etl::optional& rhs) -{ - if (bool(lhs) != bool(rhs)) - { - return false; - } - else if (!bool(lhs) && !bool(rhs)) - { - return true; - } - else - { - return lhs.value() == rhs.value(); - } -} - -//*************************************************************************** -/// Equality operator. cppreference 2 -//*************************************************************************** -template -bool operator !=(const etl::optional& lhs, const etl::optional& rhs) -{ - return !(lhs == rhs); -} - -//*************************************************************************** -/// Less than operator. cppreference 3 -//*************************************************************************** -template -bool operator <(const etl::optional& lhs, const etl::optional& rhs) -{ - if (!bool(rhs)) - { - return false; - } - else if (!bool(lhs)) - { - return true; - } - else - { - return lhs.value() < rhs.value(); - } -} - -//*************************************************************************** -/// Less than equal operator. cppreference 4 -//*************************************************************************** -template -bool operator <=(const etl::optional& lhs, const etl::optional& rhs) -{ - if (!bool(lhs)) - { - return true; - } - else if (!bool(rhs)) - { - return false; - } - else - { - return lhs.value() <= rhs.value(); - } -} - -//*************************************************************************** -/// greater than operator. cppreference 5 -//*************************************************************************** -template -bool operator >(const etl::optional& lhs, const etl::optional& rhs) -{ - if (!bool(lhs)) - { - return false; - } - else if (!bool(rhs)) - { - return true; - } - else - { - return lhs.value() > rhs.value(); - } -} - -//*************************************************************************** -/// greater than equal operator. cppreference 6 -//*************************************************************************** -template -bool operator >=(const etl::optional& lhs, const etl::optional& rhs) -{ - if (!bool(rhs)) - { - return true; - } - else if (!bool(lhs)) - { - return false; - } - else - { - return lhs.value() >= rhs.value(); - } -} - -//*************************************************************************** -/// Equality operator. cppreference 7 -//*************************************************************************** -template -bool operator ==(const etl::optional& lhs, etl::nullopt_t) -{ - return !bool(lhs); -} - -//*************************************************************************** -/// Equality operator. cppreference 8 -//*************************************************************************** -template -bool operator ==(etl::nullopt_t, const etl::optional& rhs) -{ - return !bool(rhs); -} - -//*************************************************************************** -/// Inequality operator. cppreference 9 -//*************************************************************************** -template -bool operator !=(const etl::optional& lhs, etl::nullopt_t) -{ - return !(lhs == etl::nullopt); -} - -//*************************************************************************** -/// Inequality operator. cppreference 10 -//*************************************************************************** -template -bool operator !=(etl::nullopt_t , const etl::optional& rhs) -{ - return !(etl::nullopt == rhs); -} - -//*************************************************************************** -/// Less than operator. cppreference 11 -//*************************************************************************** -template -bool operator <(const etl::optional&, etl::nullopt_t) -{ - return false; -} - -//*************************************************************************** -/// Less than operator. cppreference 12 -//*************************************************************************** -template -bool operator <(etl::nullopt_t, const etl::optional& rhs) -{ - return bool(rhs); -} - -//*************************************************************************** -/// Less than equal operator. cppreference 13 -//*************************************************************************** -template -bool operator <=(const etl::optional& lhs, etl::nullopt_t) -{ - return !bool(lhs); -} - -//*************************************************************************** -/// Less than equal operator. cppreference 14 -//*************************************************************************** -template -bool operator <=(etl::nullopt_t, const etl::optional&) -{ - return true; -} - -//*************************************************************************** -/// Greater than operator. cppreference 15 -//*************************************************************************** -template -bool operator >(const etl::optional& lhs, etl::nullopt_t) -{ - return bool(lhs); -} - -//*************************************************************************** -/// Greater than operator. cppreference 16 -//*************************************************************************** -template -bool operator >(etl::nullopt_t, const etl::optional&) -{ - return false; -} - -//*************************************************************************** -/// Greater than equal operator. cppreference 17 -//*************************************************************************** -template -bool operator >=(const etl::optional&, etl::nullopt_t) -{ - return true; -} - -//*************************************************************************** -/// Greater than equal operator. cppreference 18 -//*************************************************************************** -template -bool operator >=(etl::nullopt_t, const etl::optional& rhs) -{ - return !bool(rhs); -} - -//*************************************************************************** -/// Equality operator. cppreference 19 -//************************************************************************** -template -bool operator ==(const etl::optional& lhs, const U& rhs) -{ - return bool(lhs) ? lhs.value() == rhs : false; -} - -//*************************************************************************** -/// Inequality operator. cppreference 21 -//************************************************************************** -template -bool operator !=(const etl::optional& lhs, const U& rhs) -{ - return !(lhs == rhs); -} - -//*************************************************************************** -/// Equality operator. cppreference 20 -//************************************************************************** -template -bool operator ==(const U& lhs, const etl::optional& rhs) -{ - return bool(rhs) ? rhs.value() == lhs : false; -} - -//*************************************************************************** -/// Inequality operator. cppreference 22 -//************************************************************************** -template -bool operator !=(const U& lhs, const etl::optional& rhs) -{ - return !(lhs == rhs); -} - -//*************************************************************************** -/// Less than operator. cppreference 23 -//*************************************************************************** -template -bool operator <(const etl::optional& lhs, const U& rhs) -{ - return bool(lhs) ? lhs.value() < rhs : true; -} - -//*************************************************************************** -/// Less than operator. cppreference 24 -//*************************************************************************** -template -bool operator <(const U& lhs, const etl::optional& rhs) -{ - return bool(rhs) ? lhs < rhs.value() : false; -} - -//*************************************************************************** -/// Less than equal operator. cppreference 25 -//*************************************************************************** -template -bool operator <=(const etl::optional& lhs, const U& rhs) -{ - return bool(lhs) ? lhs.value() <= rhs : true; -} - -//*************************************************************************** -/// Less than equal operator. cppreference 26 -//*************************************************************************** -template -bool operator <=(const U& lhs, const etl::optional& rhs) -{ - return bool(rhs) ? lhs <= rhs.value() : false; -} - -//*************************************************************************** -/// Greater than operator. cppreference 27 -//*************************************************************************** -template -bool operator >(const etl::optional& lhs, const U& rhs) -{ - return bool(lhs) ? lhs.value() > rhs : false; -} - -//*************************************************************************** -/// Greater than operator. cppreference 28 -//*************************************************************************** -template -bool operator >(const U& lhs, const etl::optional& rhs) -{ - return bool(rhs) ? lhs > rhs.value() : true; -} - -//*************************************************************************** -/// Greater than equal operator. cppreference 29 -//*************************************************************************** -template -bool operator >=(const etl::optional& lhs, const U& rhs) -{ - return bool(lhs) ? lhs.value() >= rhs : false; -} - -//*************************************************************************** -/// Greater than equal operator. cppreference 30 -//*************************************************************************** -template -bool operator >=(const U& lhs, const etl::optional& rhs) -{ - return bool(rhs) ? lhs >= rhs.value() : true; -} - -//*************************************************************************** -/// Make an optional. -//*************************************************************************** -template -etl::optional::type> make_optional(T& value) -{ - return etl::optional::type>(value); -} - #endif diff --git a/include/etl/set.h b/include/etl/set.h index 9edfeec1..57035d19 100644 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -2023,87 +2023,87 @@ namespace etl /// The pool of data nodes used for the set. etl::pool::Data_Node, MAX_SIZE> node_pool; }; -} -//*************************************************************************** -/// Equal operator. -///\param lhs Reference to the first lookup. -///\param rhs Reference to the second lookup. -///\return true if the arrays are equal, otherwise false -///\ingroup lookup -//*************************************************************************** -template -bool operator ==(const etl::iset& lhs, const etl::iset& rhs) -{ - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); -} + //*************************************************************************** + /// Equal operator. + ///\param lhs Reference to the first lookup. + ///\param rhs Reference to the second lookup. + ///\return true if the arrays are equal, otherwise false + ///\ingroup lookup + //*************************************************************************** + template + bool operator ==(const etl::iset& lhs, const etl::iset& rhs) + { + return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + } -//*************************************************************************** -/// Not equal operator. -///\param lhs Reference to the first lookup. -///\param rhs Reference to the second lookup. -///\return true if the arrays are not equal, otherwise false -///\ingroup lookup -//*************************************************************************** -template -bool operator !=(const etl::iset& lhs, const etl::iset& rhs) -{ - return !(lhs == rhs); -} + //*************************************************************************** + /// Not equal operator. + ///\param lhs Reference to the first lookup. + ///\param rhs Reference to the second lookup. + ///\return true if the arrays are not equal, otherwise false + ///\ingroup lookup + //*************************************************************************** + template + bool operator !=(const etl::iset& lhs, const etl::iset& rhs) + { + return !(lhs == rhs); + } -//************************************************************************* -/// Less than operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically less than the -/// second, otherwise false. -//************************************************************************* -template -bool operator <(const etl::iset& lhs, const etl::iset& rhs) -{ - return std::lexicographical_compare(lhs.begin(), - lhs.end(), - rhs.begin(), - rhs.end()); -} + //************************************************************************* + /// Less than operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically less than the + /// second, otherwise false. + //************************************************************************* + template + bool operator <(const etl::iset& lhs, const etl::iset& rhs) + { + return std::lexicographical_compare(lhs.begin(), + lhs.end(), + rhs.begin(), + rhs.end()); + } -//************************************************************************* -/// Greater than operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically greater than the -/// second, otherwise false. -//************************************************************************* -template -bool operator >(const etl::iset& lhs, const etl::iset& rhs) -{ - return (rhs < lhs); -} + //************************************************************************* + /// Greater than operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically greater than the + /// second, otherwise false. + //************************************************************************* + template + bool operator >(const etl::iset& lhs, const etl::iset& rhs) + { + return (rhs < lhs); + } -//************************************************************************* -/// Less than or equal operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically less than or equal -/// to the second, otherwise false. -//************************************************************************* -template -bool operator <=(const etl::iset& lhs, const etl::iset& rhs) -{ - return !(lhs > rhs); -} + //************************************************************************* + /// Less than or equal operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically less than or equal + /// to the second, otherwise false. + //************************************************************************* + template + bool operator <=(const etl::iset& lhs, const etl::iset& rhs) + { + return !(lhs > rhs); + } -//************************************************************************* -/// Greater than or equal operator. -///\param lhs Reference to the first list. -///\param rhs Reference to the second list. -///\return true if the first list is lexicographically greater than or -/// equal to the second, otherwise false. -//************************************************************************* -template -bool operator >=(const etl::iset& lhs, const etl::iset& rhs) -{ - return !(lhs < rhs); + //************************************************************************* + /// Greater than or equal operator. + ///\param lhs Reference to the first list. + ///\param rhs Reference to the second list. + ///\return true if the first list is lexicographically greater than or + /// equal to the second, otherwise false. + //************************************************************************* + template + bool operator >=(const etl::iset& lhs, const etl::iset& rhs) + { + return !(lhs < rhs); + } } #include "private/minmax_pop.h"