view: add container/view equality operators

This commit is contained in:
Danny Robson 2017-12-19 18:13:32 +11:00
parent e61c4f6e98
commit 62d5dfcf64

View File

@ -309,6 +309,42 @@ namespace util {
}
//-------------------------------------------------------------------------
template <typename IteratorT, typename ContainerT>
constexpr bool
operator== (const ContainerT &a, const view<IteratorT> &b)
{
return make_view (a) == b;
}
//-------------------------------------------------------------------------
template <typename IteratorT, typename ContainerT>
constexpr bool
operator!= (const ContainerT &b, const view<IteratorT> &a)
{
return !(a == b);
}
//-------------------------------------------------------------------------
template <typename IteratorT, typename ContainerT>
constexpr bool
operator== (const view<IteratorT> &a, const ContainerT &b)
{
return a == make_view (b);
}
//-------------------------------------------------------------------------
template <typename IteratorT, typename ContainerT>
constexpr bool
operator!= (const view<IteratorT> &a, const ContainerT &b)
{
return !(a == b);
}
//-------------------------------------------------------------------------
// equality operations for string-like views against std::strings
bool equal (const std::string&, view<const char*>);