Naios / function2

Improved and configurable drop-in replacement to std::function that supports move only types, multiple overloads and more
http://naios.github.io/function2
Boost Software License 1.0
545 stars 46 forks source link

Missing explicit bool operator() #3

Closed Klaim closed 8 years ago

Klaim commented 8 years ago

std::function have an explicit bool operator to allow it's user to evaluate if it contains something or not. Your function implementations does not, but it's necessary for code that stores optional callbacks and want to check if there is something to call before calling.

Looking at the code, it seems to me that in storage_t, impl_t could be set to nullptr when there is nothing assigned. I'm trying this solution at the moment but I don't know if it's the best one yet.

Klaim commented 8 years ago

Pull request #4 seems to work for me, I mean your tests pass and mine too (when used in my code that was previously using std::function but now is using unique_function).

Naios commented 8 years ago

Fixed in 4456d92962e290445e2dfc7c66a074c5027ed454, thanks for your improvement.