Skip to content

Commit

Permalink
noncopyable_function add bool operator
Browse files Browse the repository at this point in the history
std::functions can be check it it was set or not, noncopyable_function
should behave the same, so if f is a noncopyable_function

if (f) should be true if f was set, or false if not.

This patch adds a bool operator to noncopyable_function

Signed-off-by: Amnon Heiman <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
amnonh authored and avikivity committed Oct 9, 2017
1 parent daa44a8 commit 348fc38
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions util/noncopyable_function.hh
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ public:
Ret operator()(Args... args) const {
return _vtable->call(this, std::forward<Args>(args)...);
}

explicit operator bool() const {
return _vtable != &_s_empty_vtable;
}
};


Expand Down

0 comments on commit 348fc38

Please sign in to comment.