annotate DEPENDENCIES/generic/include/boost/asio/use_future.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //
Chris@16 2 // use_future.hpp
Chris@16 3 // ~~~~~~~~~~~~~~
Chris@16 4 //
Chris@101 5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Chris@16 6 //
Chris@16 7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 //
Chris@16 10
Chris@16 11 #ifndef BOOST_ASIO_USE_FUTURE_HPP
Chris@16 12 #define BOOST_ASIO_USE_FUTURE_HPP
Chris@16 13
Chris@16 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 15 # pragma once
Chris@16 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 17
Chris@16 18 #include <boost/asio/detail/config.hpp>
Chris@16 19 #include <memory>
Chris@16 20
Chris@16 21 #include <boost/asio/detail/push_options.hpp>
Chris@16 22
Chris@16 23 namespace boost {
Chris@16 24 namespace asio {
Chris@16 25
Chris@16 26 /// Class used to specify that an asynchronous operation should return a future.
Chris@16 27 /**
Chris@16 28 * The use_future_t class is used to indicate that an asynchronous operation
Chris@16 29 * should return a std::future object. A use_future_t object may be passed as a
Chris@16 30 * handler to an asynchronous operation, typically using the special value @c
Chris@16 31 * boost::asio::use_future. For example:
Chris@16 32 *
Chris@16 33 * @code std::future<std::size_t> my_future
Chris@16 34 * = my_socket.async_read_some(my_buffer, boost::asio::use_future); @endcode
Chris@16 35 *
Chris@16 36 * The initiating function (async_read_some in the above example) returns a
Chris@16 37 * future that will receive the result of the operation. If the operation
Chris@16 38 * completes with an error_code indicating failure, it is converted into a
Chris@16 39 * system_error and passed back to the caller via the future.
Chris@16 40 */
Chris@16 41 template <typename Allocator = std::allocator<void> >
Chris@16 42 class use_future_t
Chris@16 43 {
Chris@16 44 public:
Chris@16 45 /// The allocator type. The allocator is used when constructing the
Chris@16 46 /// @c std::promise object for a given asynchronous operation.
Chris@16 47 typedef Allocator allocator_type;
Chris@16 48
Chris@16 49 /// Construct using default-constructed allocator.
Chris@16 50 BOOST_ASIO_CONSTEXPR use_future_t()
Chris@16 51 {
Chris@16 52 }
Chris@16 53
Chris@16 54 /// Construct using specified allocator.
Chris@16 55 explicit use_future_t(const Allocator& allocator)
Chris@16 56 : allocator_(allocator)
Chris@16 57 {
Chris@16 58 }
Chris@16 59
Chris@16 60 /// Specify an alternate allocator.
Chris@16 61 template <typename OtherAllocator>
Chris@16 62 use_future_t<OtherAllocator> operator[](const OtherAllocator& allocator) const
Chris@16 63 {
Chris@16 64 return use_future_t<OtherAllocator>(allocator);
Chris@16 65 }
Chris@16 66
Chris@16 67 /// Obtain allocator.
Chris@16 68 allocator_type get_allocator() const
Chris@16 69 {
Chris@16 70 return allocator_;
Chris@16 71 }
Chris@16 72
Chris@16 73 private:
Chris@16 74 Allocator allocator_;
Chris@16 75 };
Chris@16 76
Chris@16 77 /// A special value, similar to std::nothrow.
Chris@16 78 /**
Chris@16 79 * See the documentation for boost::asio::use_future_t for a usage example.
Chris@16 80 */
Chris@16 81 #if defined(BOOST_ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
Chris@16 82 constexpr use_future_t<> use_future;
Chris@16 83 #elif defined(BOOST_ASIO_MSVC)
Chris@16 84 __declspec(selectany) use_future_t<> use_future;
Chris@16 85 #endif
Chris@16 86
Chris@16 87 } // namespace asio
Chris@16 88 } // namespace boost
Chris@16 89
Chris@16 90 #include <boost/asio/detail/pop_options.hpp>
Chris@16 91
Chris@16 92 #include <boost/asio/impl/use_future.hpp>
Chris@16 93
Chris@16 94 #endif // BOOST_ASIO_USE_FUTURE_HPP