view: add assertion that orderable iterators are ordered

This commit is contained in:
Danny Robson 2019-01-18 17:19:10 +11:00
parent c533b4103e
commit e7ba296011

View File

@ -22,6 +22,7 @@
#include <cstring> #include <cstring>
#include <stdexcept> #include <stdexcept>
#include <iterator> #include <iterator>
#include <type_traits>
namespace cruft { namespace cruft {
template <typename BeginT, typename EndT = BeginT> template <typename BeginT, typename EndT = BeginT>
@ -42,7 +43,11 @@ namespace cruft {
view (const BeginT &first, const EndT &last) noexcept: view (const BeginT &first, const EndT &last) noexcept:
m_begin (first), m_begin (first),
m_end (last) m_end (last)
{ ; } {
if constexpr (cruft::is_orderable_v<BeginT> && cruft::is_orderable_v<EndT>) {
CHECK_LE (m_begin, m_end);
}
}
template < template <
@ -97,8 +102,10 @@ namespace cruft {
> >
> >
view (const view<const ValueT*const*,const ValueT*const*> &rhs): view (const view<const ValueT*const*,const ValueT*const*> &rhs):
m_begin (const_cast<const ValueT**> (rhs.begin ())), view (
m_end (const_cast<const ValueT**> (rhs.end ())) const_cast<const ValueT**> (rhs.begin ()),
const_cast<const ValueT**> (rhs.end ())
)
{ ; } { ; }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
@ -111,8 +118,7 @@ namespace cruft {
> >
> >
view (const view<ValueT*,ValueT*> &rhs): view (const view<ValueT*,ValueT*> &rhs):
m_begin (rhs.begin ()), view (rhs.begin (), rhs.end ())
m_end (rhs.end ())
{ ; } { ; }