-
Notifications
You must be signed in to change notification settings - Fork 23
QuantumGate::MakeCallback
Karel Donk edited this page Jun 15, 2018
·
1 revision
Makes a QuantumGate::Callback
object.
template<typename F>
constexpr auto MakeCallback(F&& function) noexcept(/*condition*/)
template<typename T, typename F>
constexpr auto MakeCallback(T* object, F&& member_function) noexcept;
Name | Description |
---|---|
function |
A function pointer or a callable object. |
object |
A pointer to an object. |
member_function |
A member function pointer to invoke on object . |
The overload accepting callable objects (lambdas etc.) may throw exceptions if memory allocation or move assignment fails.
int FreeTestFunction(int n) noexcept
{
return 10;
}
class TestClass
{
public:
int MemberTestFunction(int n)
{
return 10;
}
};
// Function pointer example
auto cb = MakeCallback(&FreeTestFunction);
// Lambda example
auto cb2 = MakeCallback([](int n){ return 10; });
// Member function pointer example
TestClass t;
auto cb3 = MakeCallback(&t, &TestClass::MemberTestFunction);