Poplar and PopLibs
poplar::HostCallbackHandle Class Reference

Wrapper for HostCallback instances. More...

#include <HostFunctionCallback.hpp>

Public Member Functions

template<class CallbackImpl , typename = typename std::enable_if< std::is_base_of<HostCallback, CallbackImpl>::value>::type>
 HostCallbackHandle (std::unique_ptr< CallbackImpl > f)
 Constructs a handle from an instance of a host callback implementation. More...
 
template<class F , typename = typename std::enable_if< traits::is_host_callback<F>::value>::type>
 HostCallbackHandle (F &&f)
 Constructs a handle from a callable instance. More...
 
 operator std::unique_ptr< HostCallback > () &&
 Extracts the callback implementation from the handle.
 

Detailed Description

Wrapper for HostCallback instances.

Provides a way to specify a callback using one of the following options:

  • An implementation of the HostCallback interface
  • A C++ lambda expression
  • An instance of std::function

Constructor & Destructor Documentation

◆ HostCallbackHandle() [1/2]

template<class CallbackImpl , typename = typename std::enable_if< std::is_base_of<HostCallback, CallbackImpl>::value>::type>
poplar::HostCallbackHandle::HostCallbackHandle ( std::unique_ptr< CallbackImpl >  f)
inline

Constructs a handle from an instance of a host callback implementation.

This constructor only participates in overload resolution if CallbackImpl is derived from poplar::HostCallback (in other words, it is an implementation of the host callback interface).

◆ HostCallbackHandle() [2/2]

template<class F , typename = typename std::enable_if< traits::is_host_callback<F>::value>::type>
poplar::HostCallbackHandle::HostCallbackHandle ( F &&  f)
inline

Constructs a handle from a callable instance.

This constructor only participates in overload resolution if F satisfies the requirements of a Function Object. It transforms f into a HostCallback implementation.

See also
https://en.cppreference.com/w/cpp/named_req/FunctionObject

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