diff --git a/include/boost/utility/string_ref.hpp b/include/boost/utility/string_ref.hpp index 6e8ecc5..ffadb2e 100644 --- a/include/boost/utility/string_ref.hpp +++ b/include/boost/utility/string_ref.hpp @@ -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(0) / (sizeof(value_type) * 2u); } BOOST_CONSTEXPR bool empty() const { return len_ == 0; } // element access diff --git a/include/boost/utility/string_view.hpp b/include/boost/utility/string_view.hpp index 30837e4..fe1cfa0 100644 --- a/include/boost/utility/string_view.hpp +++ b/include/boost/utility/string_view.hpp @@ -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(0) / (sizeof(value_type) * 2u); } BOOST_CONSTEXPR bool empty() const BOOST_NOEXCEPT { return len_ == 0; } // element access