static_buffer.hpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. //
  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)
  6. //
  7. // Official repository: https://github.com/boostorg/beast
  8. //
  9. #ifndef BOOST_BEAST_IMPL_STATIC_BUFFER_HPP
  10. #define BOOST_BEAST_IMPL_STATIC_BUFFER_HPP
  11. #include <boost/asio/buffer.hpp>
  12. #include <stdexcept>
  13. namespace boost {
  14. namespace beast {
  15. template<std::size_t N>
  16. static_buffer<N>::
  17. static_buffer(static_buffer const& other) noexcept
  18. : static_buffer_base(buf_, N)
  19. {
  20. this->commit(net::buffer_copy(
  21. this->prepare(other.size()), other.data()));
  22. }
  23. template<std::size_t N>
  24. auto
  25. static_buffer<N>::
  26. operator=(static_buffer const& other) noexcept ->
  27. static_buffer<N>&
  28. {
  29. if(this == &other)
  30. return *this;
  31. this->consume(this->size());
  32. this->commit(net::buffer_copy(
  33. this->prepare(other.size()), other.data()));
  34. return *this;
  35. }
  36. } // beast
  37. } // boost
  38. #endif