forked from boostorg/beast
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
@@ -215,8 +216,8 @@ private:
|
||||
reference
|
||||
dereference(C<sizeof...(Bn)> const&) const
|
||||
{
|
||||
throw detail::make_exception<std::logic_error>(
|
||||
"invalid iterator", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::logic_error{
|
||||
"invalid iterator"});
|
||||
}
|
||||
|
||||
template<std::size_t I>
|
||||
@@ -232,8 +233,8 @@ private:
|
||||
void
|
||||
increment(C<sizeof...(Bn)> const&)
|
||||
{
|
||||
throw detail::make_exception<std::logic_error>(
|
||||
"invalid iterator", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::logic_error{
|
||||
"invalid iterator"});
|
||||
}
|
||||
|
||||
template<std::size_t I>
|
||||
@@ -274,8 +275,8 @@ private:
|
||||
--iter<I>();
|
||||
return;
|
||||
}
|
||||
throw detail::make_exception<std::logic_error>(
|
||||
"invalid iterator", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::logic_error{
|
||||
"invalid iterator"});
|
||||
}
|
||||
|
||||
template<std::size_t I>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -197,7 +198,7 @@ read_some(
|
||||
error_code ec;
|
||||
auto n = read_some(buffers, ec);
|
||||
if(ec)
|
||||
throw system_error{ec};
|
||||
BOOST_THROW_EXCEPTION(system_error{ec});
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
@@ -414,8 +415,8 @@ buffers_adapter<MutableBufferSequence>::prepare(std::size_t n) ->
|
||||
}
|
||||
}
|
||||
if(n > 0)
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"no space", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"no space"});
|
||||
return mutable_buffers_type{*this};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define BEAST_IMPL_FLAT_BUFFER_HPP
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace beast {
|
||||
@@ -211,8 +212,8 @@ prepare(std::size_t n) ->
|
||||
}
|
||||
// enforce maximum capacity
|
||||
if(n > max_ - len)
|
||||
throw std::length_error{
|
||||
"basic_flat_buffer overflow"};
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"basic_flat_buffer overflow"});
|
||||
// allocate a new buffer
|
||||
auto const new_size = (std::min)(max_,
|
||||
std::max<std::size_t>(
|
||||
@@ -257,8 +258,8 @@ reserve(std::size_t n)
|
||||
if(n <= capacity())
|
||||
return;
|
||||
if(n > max_)
|
||||
throw std::length_error{
|
||||
"basic_flat_buffer overflow"};
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"basic_flat_buffer overflow"});
|
||||
auto const new_size = (std::min)(max_,
|
||||
std::max<std::size_t>(
|
||||
detail::next_pow2(n), min_size));
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
#include <sstream>
|
||||
@@ -523,8 +524,8 @@ basic_multi_buffer<Allocator>::basic_multi_buffer(
|
||||
, alloc_size_(alloc_size)
|
||||
{
|
||||
if(alloc_size <= 0)
|
||||
throw detail::make_exception<std::invalid_argument>(
|
||||
"invalid alloc_size", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument{
|
||||
"invalid alloc_size"});
|
||||
}
|
||||
|
||||
template<class Allocator>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
@@ -295,8 +296,8 @@ static_buffer::prepare(std::size_t n) ->
|
||||
mutable_buffers_type
|
||||
{
|
||||
if(n > static_cast<std::size_t>(end_ - out_))
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"static_buffer overflow", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"static_buffer overflow"});
|
||||
last_ = out_ + n;
|
||||
return mutable_buffers_type{out_, n};
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define BEAST_IMPL_STATIC_STRING_IPP
|
||||
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -119,8 +120,8 @@ assign(size_type count, CharT ch) ->
|
||||
static_string&
|
||||
{
|
||||
if(count > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"count > max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"count > max_size()"});
|
||||
n_ = count;
|
||||
Traits::assign(&s_[0], n_, ch);
|
||||
term();
|
||||
@@ -157,8 +158,8 @@ assign(CharT const* s, size_type count) ->
|
||||
static_string&
|
||||
{
|
||||
if(count > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"count > max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"count > max_size()"});
|
||||
n_ = count;
|
||||
Traits::copy(&s_[0], s, n_);
|
||||
term();
|
||||
@@ -174,8 +175,8 @@ assign(InputIt first, InputIt last) ->
|
||||
{
|
||||
std::size_t const n = std::distance(first, last);
|
||||
if(n > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"n > max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"n > max_size()"});
|
||||
n_ = n;
|
||||
for(auto it = &s_[0]; first != last; ++it, ++first)
|
||||
Traits::assign(*it, *first);
|
||||
@@ -193,8 +194,8 @@ assign(T const& t, size_type pos, size_type count) ->
|
||||
{
|
||||
auto const sv = string_view_type(t).substr(pos, count);
|
||||
if(sv.size() > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"sv.size() > max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"sv.size() > max_size()"});
|
||||
n_ = sv.size();
|
||||
Traits::copy(&s_[0], &sv[0], n_);
|
||||
term();
|
||||
@@ -212,8 +213,8 @@ at(size_type pos) ->
|
||||
reference
|
||||
{
|
||||
if(pos >= size())
|
||||
throw detail::make_exception<std::out_of_range>(
|
||||
"pos >= size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||
"pos >= size()"});
|
||||
return s_[pos];
|
||||
}
|
||||
|
||||
@@ -224,8 +225,8 @@ at(size_type pos) const ->
|
||||
const_reference
|
||||
{
|
||||
if(pos >= size())
|
||||
throw detail::make_exception<std::out_of_range>(
|
||||
"pos >= size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||
"pos >= size()"});
|
||||
return s_[pos];
|
||||
}
|
||||
|
||||
@@ -239,8 +240,8 @@ static_string<N, CharT, Traits>::
|
||||
reserve(std::size_t n)
|
||||
{
|
||||
if(n > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"n > max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"n > max_size()"});
|
||||
}
|
||||
|
||||
//
|
||||
@@ -263,8 +264,8 @@ insert(size_type index, size_type count, CharT ch) ->
|
||||
static_string&
|
||||
{
|
||||
if(index > size())
|
||||
throw detail::make_exception<std::out_of_range>(
|
||||
"index > size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||
"index > size()"});
|
||||
insert(begin() + index, count, ch);
|
||||
return *this;
|
||||
}
|
||||
@@ -276,11 +277,11 @@ insert(size_type index, CharT const* s, size_type count) ->
|
||||
static_string&
|
||||
{
|
||||
if(index > size())
|
||||
throw detail::make_exception<std::out_of_range>(
|
||||
"index > size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||
"index > size()"});
|
||||
if(size() + count > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"size() + count > max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"size() + count > max_size()"});
|
||||
Traits::move(
|
||||
&s_[index + count], &s_[index], size() - index);
|
||||
n_ += count;
|
||||
@@ -309,8 +310,8 @@ insert(const_iterator pos, size_type count, CharT ch) ->
|
||||
iterator
|
||||
{
|
||||
if(size() + count > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"size() + count() > max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"size() + count() > max_size()"});
|
||||
auto const index = pos - &s_[0];
|
||||
Traits::move(
|
||||
&s_[index + count], &s_[index], size() - index);
|
||||
@@ -331,8 +332,8 @@ insert(const_iterator pos, InputIt first, InputIt last) ->
|
||||
{
|
||||
std::size_t const count = std::distance(first, last);
|
||||
if(size() + count > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"size() + count > max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"size() + count > max_size()"});
|
||||
std::size_t const index = pos - begin();
|
||||
Traits::move(
|
||||
&s_[index + count], &s_[index], size() - index);
|
||||
@@ -367,8 +368,8 @@ erase(size_type index, size_type count) ->
|
||||
static_string&
|
||||
{
|
||||
if(index > size())
|
||||
throw detail::make_exception<std::out_of_range>(
|
||||
"index > size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||
"index > size()"});
|
||||
auto const n = (std::min)(count, size() - index);
|
||||
Traits::move(
|
||||
&s_[index], &s_[index + n], size() - (index + n) + 1);
|
||||
@@ -403,8 +404,8 @@ static_string<N, CharT, Traits>::
|
||||
push_back(CharT ch)
|
||||
{
|
||||
if(size() >= max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"size() >= max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"size() >= max_size()"});
|
||||
Traits::assign(s_[n_++], ch);
|
||||
term();
|
||||
}
|
||||
@@ -419,8 +420,8 @@ append(static_string<M, CharT, Traits> const& str,
|
||||
{
|
||||
// Valid range is [0, size)
|
||||
if(pos >= str.size())
|
||||
throw detail::make_exception<std::out_of_range>(
|
||||
"pos > str.size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||
"pos > str.size()"});
|
||||
string_view_type const ss{&str.s_[pos],
|
||||
(std::min)(count, str.size() - pos)};
|
||||
insert(size(), ss.data(), ss.size());
|
||||
@@ -434,8 +435,8 @@ substr(size_type pos, size_type count) const ->
|
||||
string_view_type
|
||||
{
|
||||
if(pos > size())
|
||||
throw detail::make_exception<std::out_of_range>(
|
||||
"pos > size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||
"pos > size()"});
|
||||
return{&s_[pos], (std::min)(count, size() - pos)};
|
||||
}
|
||||
|
||||
@@ -456,8 +457,8 @@ static_string<N, CharT, Traits>::
|
||||
resize(std::size_t n)
|
||||
{
|
||||
if(n > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"n > max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"n > max_size()"});
|
||||
n_ = n;
|
||||
term();
|
||||
}
|
||||
@@ -468,8 +469,8 @@ static_string<N, CharT, Traits>::
|
||||
resize(std::size_t n, CharT c)
|
||||
{
|
||||
if(n > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"n > max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"n > max_size()"});
|
||||
if(n > n_)
|
||||
Traits::assign(&s_[n_], n - n_, c);
|
||||
n_ = n;
|
||||
@@ -495,11 +496,11 @@ static_string<N, CharT, Traits>::
|
||||
swap(static_string<M, CharT, Traits>& str)
|
||||
{
|
||||
if(size() > str.max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"size() > str.max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"size() > str.max_size()"});
|
||||
if(str.size() > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"str.size() > max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"str.size() > max_size()"});
|
||||
static_string tmp(str);
|
||||
str.n_ = n_;
|
||||
Traits::copy(&str.s_[0], &s_[0], n_ + 1);
|
||||
@@ -526,8 +527,8 @@ static_string<N, CharT, Traits>::
|
||||
assign_char(CharT ch, std::false_type) ->
|
||||
static_string&
|
||||
{
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"max_size() == 0", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"max_size() == 0"});
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
Reference in New Issue
Block a user