Skip to content

Commit

Permalink
better subview
Browse files Browse the repository at this point in the history
fix #708
  • Loading branch information
vinniefalco committed May 26, 2022
1 parent c4ab4dd commit bc64ded
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions include/boost/json/string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2246,13 +2246,23 @@ class string
@throw std::out_of_range `pos > size()`
*/
/**@{*/
string_view
subview(
std::size_t pos = 0,
std::size_t pos,
std::size_t count = npos) const
{
return string_view(*this).substr(pos, count);
return subview().substr(pos, count);
}

// this is a faster, leaner, noexcept
// version of subview() with no args
string_view
subview() const noexcept
{
return string_view( data(), size() );
}
/**@}*/

//------------------------------------------------------

Expand Down

0 comments on commit bc64ded

Please sign in to comment.