CppWAMP
C++11 client library for the WAMP protocol
wamp::AnyReusableHandler< TSignature > Class Template Reference

Type-erases a multi-shot, copyable callback handler. More...

#include <cppwamp/anyhandler.hpp>

Public Types

using Executor = AnyCompletionExecutor
 Polymorphic wrapper around the executor associated with this handler.
 
using CancellationSlot = boost::asio::cancellation_slot
 Cancellation slot type used by this handler.
 
using executor_type = Executor
 Asio-conformant type alias.
 
using cancellation_slot_type = CancellationSlot
 Asio-conformant type alias.
 

Public Member Functions

 AnyReusableHandler ()=default
 Default constructor.
 
 AnyReusableHandler (const AnyReusableHandler &)=default
 Copy constructor.
 
 AnyReusableHandler (AnyReusableHandler &&) noexcept=default
 Move constructor.
 
template<typename S , typename std::enable_if< otherConstructible< S >(), int >::type = 0>
 AnyReusableHandler (const AnyReusableHandler< S > &rhs)
 Constructor copying another AnyReusableHandler with a different signature. More...
 
template<typename S , typename std::enable_if< otherConstructible< S >(), int >::type = 0>
 AnyReusableHandler (AnyReusableHandler< S > &&rhs) noexcept
 Constructor moving another AnyReusableHandler with a different signature. More...
 
template<typename F , typename std::enable_if< fnConstructible< F >(), int >::type = 0>
 AnyReusableHandler (F &&handler)
 Constructor taking a callable entity. More...
 
 AnyReusableHandler (std::nullptr_t) noexcept
 Constructs an empty AnyReusableHandler.
 
AnyReusableHandleroperator= (std::nullptr_t) noexcept
 Renders an AnyReusableHandler empty.
 
AnyReusableHandleroperator= (const AnyReusableHandler &)=default
 Copy assignment.
 
AnyReusableHandleroperator= (AnyReusableHandler &&) noexcept=default
 Move assignment.
 
void swap (AnyReusableHandler &rhs) noexcept
 Swaps contents with another AnyReusableHandler.
 
 operator bool () const noexcept
 Returns false iff the AnyReusableHandler is empty.
 
const Executorget_executor () const
 Obtains the executor associated with this handler.
 
const CancellationSlotget_cancellation_slot () const
 Obtains the cancellation slot associated with this handler.
 
template<typename... Ts>
auto operator() (Ts &&... args) const -> decltype(std::declval< Function >()(std::forward< Ts >(args)...))
 Invokes the handler with the given arguments.
 

Related Functions

(Note that these are not member functions.)

template<typename S >
void swap (AnyReusableHandler< S > &a, AnyReusableHandler< S > &b) noexcept
 Non-member swap.
 
template<typename S >
bool operator== (const AnyReusableHandler< S > &f, std::nullptr_t) noexcept
 Returns true is the given handler is empty.
 
template<typename S >
bool operator== (std::nullptr_t, const AnyReusableHandler< S > &f) noexcept
 Returns true is the given handler is empty.
 
template<typename S >
bool operator!= (const AnyReusableHandler< S > &f, std::nullptr_t) noexcept
 Returns false is the given handler is empty.
 
template<typename S >
bool operator!= (std::nullptr_t, const AnyReusableHandler< S > &f) noexcept
 Returns false is the given handler is empty.
 

Detailed Description

template<typename TSignature>
class wamp::AnyReusableHandler< TSignature >

Type-erases a multi-shot, copyable callback handler.

The executor associated with the type-erased handler can be obtained via boost::asio::get_associated_executor.

See also
AnyCompletionExecutor
AnyCompletionHandler

Constructor & Destructor Documentation

◆ AnyReusableHandler() [1/3]

template<typename TSignature >
template<typename S , typename std::enable_if< otherConstructible< S >(), int >::type = 0>
wamp::AnyReusableHandler< TSignature >::AnyReusableHandler ( const AnyReusableHandler< S > &  rhs)
inline

Constructor copying another AnyReusableHandler with a different signature.

Participates in overload resolution when std::is_constructible_v<std::function<TSignature>, std::function<S>> is true.

◆ AnyReusableHandler() [2/3]

template<typename TSignature >
template<typename S , typename std::enable_if< otherConstructible< S >(), int >::type = 0>
wamp::AnyReusableHandler< TSignature >::AnyReusableHandler ( AnyReusableHandler< S > &&  rhs)
inlinenoexcept

Constructor moving another AnyReusableHandler with a different signature.

Participates in overload resolution when std::is_constructible_v<std::function<TSignature>, std::function<S>> is true.

◆ AnyReusableHandler() [3/3]

template<typename TSignature >
template<typename F , typename std::enable_if< fnConstructible< F >(), int >::type = 0>
wamp::AnyReusableHandler< TSignature >::AnyReusableHandler ( F &&  handler)
inline

Constructor taking a callable entity.

Participates in overload resolution when

  • std::is_same_v<std::decay_t<F>, AnyReusableHandler<TSignature>> is false, and,
  • std::is_same_v<std::decay_t<F>, std::nullptr_t is false, and,
  • std::is_constructible_v<std::function<TSignature>, F> is true.

The documentation for this class was generated from the following file: