2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // Official repository: https://github.com/boostorg/beast
10 #ifndef BOOST_BEAST_CORE_DETAIL_BUFFER_HPP
11 #define BOOST_BEAST_CORE_DETAIL_BUFFER_HPP
13 #include <boost/beast/core/error.hpp>
14 #include <boost/asio/buffer.hpp>
15 #include <boost/optional.hpp>
26 dynamic_buffer_prepare_noexcept(
27 DynamicBuffer& buffer,
31 boost::optional<typename
32 DynamicBuffer::mutable_buffers_type>
34 if(buffer.max_size() - buffer.size() < size)
40 boost::optional<typename
41 DynamicBuffer::mutable_buffers_type> result;
42 result.emplace(buffer.prepare(size));
51 dynamic_buffer_prepare(
52 DynamicBuffer& buffer,
56 boost::optional<typename
57 DynamicBuffer::mutable_buffers_type>
59 #ifndef BOOST_NO_EXCEPTIONS
62 boost::optional<typename
63 DynamicBuffer::mutable_buffers_type> result;
64 result.emplace(buffer.prepare(size));
68 catch(std::length_error const&)
75 return dynamic_buffer_prepare_noexcept(
76 buffer, size, ec, ev);