Commit c3d9c326 authored by Max Kellermann's avatar Max Kellermann

util/BindMethod: add nullptr constructor and bool operator

parent a938b609
......@@ -60,6 +60,19 @@ public:
BoundMethod(void *_instance, function_pointer _function)
:instance_(_instance), function(_function) {}
/**
* Construct an "undefined" object. It must not be called,
* and its "bool" operator returns false.
*/
BoundMethod(std::nullptr_t):function(nullptr) {}
/**
* Was this object initialized with a valid function pointer?
*/
operator bool() const {
return function != nullptr;
}
R operator()(Args... args) const {
return function(instance_, std::forward<Args>(args)...);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment