view: add inequality operator

This commit is contained in:
Danny Robson 2017-02-20 18:10:26 +11:00
parent 09de734185
commit 7786d32ba5
3 changed files with 14 additions and 0 deletions

View File

@ -31,6 +31,7 @@ util::operator== (A a, B b) \
} }
//-----------------------------------------------------------------------------
EQUALITY(const std::string&, view<const char*>) EQUALITY(const std::string&, view<const char*>)
EQUALITY(const std::string&, view<char*>) EQUALITY(const std::string&, view<char*>)
EQUALITY(const std::string&, view<std::string::const_iterator>) EQUALITY(const std::string&, view<std::string::const_iterator>)
@ -43,6 +44,7 @@ EQUALITY(view<std::string::iterator>, const std::string&)
#undef EQUALITY #undef EQUALITY
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace util {
#define OSTREAM(A) \ #define OSTREAM(A) \

View File

@ -79,6 +79,9 @@ namespace util {
auto auto
make_cview (const T&); make_cview (const T&);
template <typename T>
bool operator!= (view<T>, view<T>);
bool operator== (const std::string&, view<const char*>); bool operator== (const std::string&, view<const char*>);
bool operator== (const std::string&, view<char*>); bool operator== (const std::string&, view<char*>);
bool operator== (const std::string&, view<std::string::const_iterator>); bool operator== (const std::string&, view<std::string::const_iterator>);

View File

@ -170,6 +170,15 @@ util::view<T>::operator== (const view<T> rhs) const noexcept
} }
//-----------------------------------------------------------------------------
template <typename T>
bool
util::operator!= (const view<T> a, const view<T> b)
{
return !(a == b);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
template <typename T, size_t N> template <typename T, size_t N>
auto auto