-
Notifications
You must be signed in to change notification settings - Fork 24
QuantumGate::Callback::Callback
Karel Donk edited this page Jun 15, 2018
·
2 revisions
Constructs a QuantumGate::Callback
object.
constexpr Callback() noexcept;
constexpr Callback(std::nullptr_t) noexcept;
template<typename F, /*condition*/>
constexpr Callback(F&& function) noexcept(/*condition*/);
template<typename T, typename F>
constexpr Callback(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 = Callback<int(int) noexcept>(&FreeTestFunction);
// Lambda example
Callback<int(int)> cb2([&](int n) -> int
{
return 10;
});
// Member function pointer example
TestClass t;
Callback<int(int)> cb3(&t, &TestClass::MemberTestFunction);