mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 21:07:26 +02:00
Add BOOST_BEAST_USE_STD_STRING_VIEW:
fix #1133, fix #1241 When the macro BOOST_BEAST_USE_STD_STRING_VIEW is defined, Beast will use std::string_view instead of boost::string_view. The name boost::beast::string_view is a type alias for the chosen view type.
This commit is contained in:
committed by
Vinnie Falco
parent
f3212eba48
commit
806979e37b
@ -2,6 +2,7 @@ Version 184:
|
||||
|
||||
* Remove extraneous function
|
||||
* Fix some typos
|
||||
* Add BOOST_BEAST_USE_STD_STRING_VIEW
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -13,6 +13,10 @@
|
||||
|
||||
[heading Boost 1.69]
|
||||
|
||||
[* New Features]
|
||||
|
||||
* ([issue 1133]) Add `BOOST_BEAST_USE_STD_STRING_VIEW`
|
||||
|
||||
[*Fixes]
|
||||
|
||||
* ([issue 1245]) Fix a rare case of incorrect UTF8 validation
|
||||
@ -25,6 +29,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
[heading Boost 1.68]
|
||||
|
||||
This version fixes a missing executor work guard in all composed operations
|
||||
|
@ -12,19 +12,35 @@
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#if defined(BOOST_BEAST_USE_STD_STRING_VIEW)
|
||||
#include <string_view>
|
||||
#else
|
||||
#include <boost/utility/string_view.hpp>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
/// The type of string view used by the library
|
||||
using string_view = boost::string_view;
|
||||
#if defined(BOOST_BEAST_USE_STD_STRING_VIEW)
|
||||
/// The type of string view used by the library
|
||||
using string_view = std::string_view;
|
||||
|
||||
/// The type of basic string view used by the library
|
||||
template<class CharT, class Traits>
|
||||
using basic_string_view =
|
||||
/// The type of basic string view used by the library
|
||||
template<class CharT, class Traits>
|
||||
using basic_string_view =
|
||||
std::basic_string_view<CharT, Traits>;
|
||||
#else
|
||||
/// The type of string view used by the library
|
||||
using string_view = boost::string_view;
|
||||
|
||||
/// The type of basic string view used by the library
|
||||
template<class CharT, class Traits>
|
||||
using basic_string_view =
|
||||
boost::basic_string_view<CharT, Traits>;
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
@ -110,7 +110,7 @@ public:
|
||||
basic_parsed_list const& list, bool at_end)
|
||||
: list_(&list)
|
||||
, it_(at_end ? nullptr :
|
||||
list.s_.begin())
|
||||
list.s_.data())
|
||||
{
|
||||
if(! at_end)
|
||||
increment();
|
||||
|
@ -429,11 +429,11 @@ struct opt_token_list_policy
|
||||
char const*& it, string_view s) const
|
||||
{
|
||||
v = {};
|
||||
auto need_comma = it != s.begin();
|
||||
auto need_comma = it != s.data();
|
||||
for(;;)
|
||||
{
|
||||
detail::skip_ows(it, s.end());
|
||||
if(it == s.end())
|
||||
detail::skip_ows(it, (s.data() + s.size()));
|
||||
if(it == (s.data() + s.size()))
|
||||
{
|
||||
it = nullptr;
|
||||
return true;
|
||||
@ -447,12 +447,12 @@ struct opt_token_list_policy
|
||||
for(;;)
|
||||
{
|
||||
++it;
|
||||
if(it == s.end())
|
||||
if(it == (s.data() + s.size()))
|
||||
break;
|
||||
if(! detail::is_token_char(*it))
|
||||
break;
|
||||
}
|
||||
v = string_view{&*p0,
|
||||
v = string_view{p0,
|
||||
static_cast<std::size_t>(it - p0)};
|
||||
return true;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ struct field_table
|
||||
{
|
||||
auto p1 = lhs.data();
|
||||
auto p2 = rhs.data();
|
||||
auto pend = lhs.end();
|
||||
auto pend = p1 + lhs.size();
|
||||
char a, b;
|
||||
while(p1 < pend)
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ string_to_verb(string_view v)
|
||||
++s;
|
||||
++p;
|
||||
if(! *s)
|
||||
return p == sv.end();
|
||||
return p == (sv.data() + sv.size());
|
||||
}
|
||||
};
|
||||
auto c = v[0];
|
||||
|
Reference in New Issue
Block a user