2 // Copyright (c) 2019 Damian Jarek(damian.jarek93@gmail.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_DETAIL_IMPL_TEMPORARY_BUFFER_IPP
11 #define BOOST_BEAST_DETAIL_IMPL_TEMPORARY_BUFFER_IPP
13 #include <boost/beast/core/detail/temporary_buffer.hpp>
14 #include <boost/beast/core/detail/clamp.hpp>
15 #include <boost/core/exchange.hpp>
16 #include <boost/assert.hpp>
34 append(string_view s1, string_view s2)
36 grow(s1.size() + s2.size());
43 unchecked_append(string_view s)
46 std::memcpy(&data_[size_], s.data(), n);
54 if (capacity_ - size_ >= n)
57 auto const capacity = (n + size_) * 2u;
58 BOOST_ASSERT(! detail::sum_exceeds(
60 char* const p = new char[capacity];
61 std::memcpy(p, data_, size_);
62 deallocate(boost::exchange(data_, p));