Fixed string_view/ref::max_size() returning incorrect value.

Fixes https://github.com/boostorg/utility/issues/91.
This commit is contained in:
Andrey Semashev 2022-05-03 00:38:15 +03:00
parent eb29d71245
commit 7ac95c156c
2 changed files with 2 additions and 2 deletions

View File

@ -128,7 +128,7 @@ namespace boost {
// capacity
BOOST_CONSTEXPR size_type size() const { return len_; }
BOOST_CONSTEXPR size_type length() const { return len_; }
BOOST_CONSTEXPR size_type max_size() const { return len_; }
BOOST_CONSTEXPR size_type max_size() const { return ~static_cast<size_type>(0) / (sizeof(value_type) * 2u); }
BOOST_CONSTEXPR bool empty() const { return len_ == 0; }
// element access

View File

@ -122,7 +122,7 @@ namespace boost {
// capacity
BOOST_CONSTEXPR size_type size() const BOOST_NOEXCEPT { return len_; }
BOOST_CONSTEXPR size_type length() const BOOST_NOEXCEPT { return len_; }
BOOST_CONSTEXPR size_type max_size() const BOOST_NOEXCEPT { return len_; }
BOOST_CONSTEXPR size_type max_size() const BOOST_NOEXCEPT { return ~static_cast<size_type>(0) / (sizeof(value_type) * 2u); }
BOOST_CONSTEXPR bool empty() const BOOST_NOEXCEPT { return len_ == 0; }
// element access