view: avoid signed comparison issues with sizes

This commit is contained in:
Danny Robson 2018-01-16 13:31:53 +11:00
parent 959617277f
commit c6d025453a

View File

@ -37,6 +37,7 @@ namespace util {
remove_restrict_t<BeginT> remove_restrict_t<BeginT>
>::value_type; >::value_type;
using size_type = size_t;
//--------------------------------------------------------------------- //---------------------------------------------------------------------
constexpr constexpr
@ -238,12 +239,12 @@ namespace util {
constexpr auto constexpr auto
size (void) const noexcept size (void) const noexcept
{ {
return static_cast<std::size_t> (std::distance (m_begin, m_end)); return static_cast<size_type> (std::distance (m_begin, m_end));
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
[[gnu::warn_unused_result]] constexpr auto [[gnu::warn_unused_result]] constexpr auto
redim (int count) const redim (size_type count) const
{ {
assert (count > 0); assert (count > 0);
if (count > size ()) if (count > size ())