// impl/buffered_write_stream.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
-#include <boost/asio/associated_allocator.hpp>
-#include <boost/asio/associated_executor.hpp>
+#include <boost/asio/associator.hpp>
#include <boost/asio/detail/handler_alloc_helpers.hpp>
#include <boost/asio/detail/handler_cont_helpers.hpp>
#include <boost/asio/detail/handler_invoke_helpers.hpp>
const std::size_t bytes_written)
{
storage_.consume(bytes_written);
- handler_(ec, bytes_written);
+ BOOST_ASIO_MOVE_OR_LVALUE(WriteHandler)(handler_)(ec, bytes_written);
}
//private:
#if !defined(GENERATING_DOCUMENTATION)
-template <typename WriteHandler, typename Allocator>
-struct associated_allocator<
- detail::buffered_flush_handler<WriteHandler>, Allocator>
+template <template <typename, typename> class Associator,
+ typename WriteHandler, typename DefaultCandidate>
+struct associator<Associator,
+ detail::buffered_flush_handler<WriteHandler>,
+ DefaultCandidate>
+ : Associator<WriteHandler, DefaultCandidate>
{
- typedef typename associated_allocator<WriteHandler, Allocator>::type type;
-
- static type get(const detail::buffered_flush_handler<WriteHandler>& h,
- const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
- {
- return associated_allocator<WriteHandler, Allocator>::get(h.handler_, a);
- }
-};
-
-template <typename WriteHandler, typename Executor>
-struct associated_executor<
- detail::buffered_flush_handler<WriteHandler>, Executor>
- : detail::associated_executor_forwarding_base<WriteHandler, Executor>
-{
- typedef typename associated_executor<WriteHandler, Executor>::type type;
-
- static type get(const detail::buffered_flush_handler<WriteHandler>& h,
- const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
+ static typename Associator<WriteHandler, DefaultCandidate>::type get(
+ const detail::buffered_flush_handler<WriteHandler>& h,
+ const DefaultCandidate& c = DefaultCandidate()) BOOST_ASIO_NOEXCEPT
{
- return associated_executor<WriteHandler, Executor>::get(h.handler_, ex);
+ return Associator<WriteHandler, DefaultCandidate>::get(h.handler_, c);
}
};
if (ec)
{
const std::size_t length = 0;
- handler_(ec, length);
+ BOOST_ASIO_MOVE_OR_LVALUE(WriteHandler)(handler_)(ec, length);
}
else
{
storage_.resize(orig_size + length);
const std::size_t bytes_copied = boost::asio::buffer_copy(
storage_.data() + orig_size, buffers_, length);
- handler_(ec, bytes_copied);
+ BOOST_ASIO_MOVE_OR_LVALUE(WriteHandler)(handler_)(ec, bytes_copied);
}
}
#if !defined(GENERATING_DOCUMENTATION)
-template <typename ConstBufferSequence,
- typename WriteHandler, typename Allocator>
-struct associated_allocator<
+template <template <typename, typename> class Associator,
+ typename ConstBufferSequence, typename WriteHandler,
+ typename DefaultCandidate>
+struct associator<Associator,
detail::buffered_write_some_handler<ConstBufferSequence, WriteHandler>,
- Allocator>
+ DefaultCandidate>
+ : Associator<WriteHandler, DefaultCandidate>
{
- typedef typename associated_allocator<WriteHandler, Allocator>::type type;
-
- static type get(
- const detail::buffered_write_some_handler<
- ConstBufferSequence, WriteHandler>& h,
- const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
- {
- return associated_allocator<WriteHandler, Allocator>::get(h.handler_, a);
- }
-};
-
-template <typename ConstBufferSequence,
- typename WriteHandler, typename Executor>
-struct associated_executor<
- detail::buffered_write_some_handler<ConstBufferSequence, WriteHandler>,
- Executor>
- : detail::associated_executor_forwarding_base<WriteHandler, Executor>
-{
- typedef typename associated_executor<WriteHandler, Executor>::type type;
-
- static type get(
+ static typename Associator<WriteHandler, DefaultCandidate>::type get(
const detail::buffered_write_some_handler<
ConstBufferSequence, WriteHandler>& h,
- const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
+ const DefaultCandidate& c = DefaultCandidate()) BOOST_ASIO_NOEXCEPT
{
- return associated_executor<WriteHandler, Executor>::get(h.handler_, ex);
+ return Associator<WriteHandler, DefaultCandidate>::get(h.handler_, c);
}
};