|
||||
File indexing completed on 2025-01-18 09:29:27
0001 // 0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) 0003 // 0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying 0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 0006 // 0007 // Official repository: https://github.com/boostorg/beast 0008 // 0009 0010 #ifndef BOOST_BEAST_BIND_HANDLER_HPP 0011 #define BOOST_BEAST_BIND_HANDLER_HPP 0012 0013 #include <boost/beast/core/detail/config.hpp> 0014 #include <boost/beast/core/detail/bind_handler.hpp> 0015 #include <type_traits> 0016 #include <utility> 0017 0018 namespace boost { 0019 namespace beast { 0020 0021 /** Bind parameters to a completion handler, creating a new handler. 0022 0023 This function creates a new handler which, when invoked, calls 0024 the original handler with the list of bound arguments. Any 0025 parameters passed in the invocation will be substituted for 0026 placeholders present in the list of bound arguments. Parameters 0027 which are not matched to placeholders are silently discarded. 0028 0029 The passed handler and arguments are forwarded into the returned 0030 handler, whose associated allocator and associated executor will 0031 be the same as those of the original handler. 0032 0033 @par Example 0034 0035 This function posts the invocation of the specified completion 0036 handler with bound arguments: 0037 0038 @code 0039 template <class AsyncReadStream, class ReadHandler> 0040 void 0041 signal_aborted (AsyncReadStream& stream, ReadHandler&& handler) 0042 { 0043 net::post( 0044 stream.get_executor(), 0045 bind_handler (std::forward <ReadHandler> (handler), 0046 net::error::operation_aborted, 0)); 0047 } 0048 @endcode 0049 0050 @param handler The handler to wrap. 0051 The implementation takes ownership of the handler by performing a decay-copy. 0052 0053 @param args A list of arguments to bind to the handler. 0054 The arguments are forwarded into the returned object. These 0055 arguments may include placeholders, which will operate in 0056 a fashion identical to a call to `std::bind`. 0057 */ 0058 template<class Handler, class... Args> 0059 #if BOOST_BEAST_DOXYGEN 0060 __implementation_defined__ 0061 #else 0062 detail::bind_wrapper< 0063 typename std::decay<Handler>::type, 0064 typename std::decay<Args>::type...> 0065 #endif 0066 bind_handler(Handler&& handler, Args&&... args) 0067 { 0068 return detail::bind_wrapper< 0069 typename std::decay<Handler>::type, 0070 typename std::decay<Args>::type...>( 0071 std::forward<Handler>(handler), 0072 std::forward<Args>(args)...); 0073 } 0074 0075 /** Bind parameters to a completion handler, creating a new handler. 0076 0077 This function creates a new handler which, when invoked, calls 0078 the original handler with the list of bound arguments. Any 0079 parameters passed in the invocation will be forwarded in 0080 the parameter list after the bound arguments. 0081 0082 The passed handler and arguments are forwarded into the returned 0083 handler, whose associated allocator and associated executor will 0084 will be the same as those of the original handler. 0085 0086 @par Example 0087 0088 This function posts the invocation of the specified completion 0089 handler with bound arguments: 0090 0091 @code 0092 template <class AsyncReadStream, class ReadHandler> 0093 void 0094 signal_eof (AsyncReadStream& stream, ReadHandler&& handler) 0095 { 0096 net::post( 0097 stream.get_executor(), 0098 bind_front_handler (std::forward<ReadHandler> (handler), 0099 net::error::eof, 0)); 0100 } 0101 @endcode 0102 0103 @param handler The handler to wrap. 0104 The implementation takes ownership of the handler by performing a decay-copy. 0105 0106 @param args A list of arguments to bind to the handler. 0107 The arguments are forwarded into the returned object. 0108 */ 0109 template<class Handler, class... Args> 0110 #if BOOST_BEAST_DOXYGEN 0111 __implementation_defined__ 0112 #else 0113 auto 0114 #endif 0115 bind_front_handler( 0116 Handler&& handler, 0117 Args&&... args) -> 0118 detail::bind_front_wrapper< 0119 typename std::decay<Handler>::type, 0120 typename std::decay<Args>::type...> 0121 { 0122 return detail::bind_front_wrapper< 0123 typename std::decay<Handler>::type, 0124 typename std::decay<Args>::type...>( 0125 std::forward<Handler>(handler), 0126 std::forward<Args>(args)...); 0127 } 0128 0129 } // beast 0130 } // boost 0131 0132 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |