BLI: support initializing empty FunctionRef with nullptr
This may sometimes be desired because it is more explicitely shows that the `FunctionRef` will be empty.
This commit is contained in:
parent
02bde2c1d5
commit
f893dea586
|
@ -110,6 +110,10 @@ template<typename Ret, typename... Params> class FunctionRef<Ret(Params...)> {
|
|||
public:
|
||||
FunctionRef() = default;
|
||||
|
||||
FunctionRef(std::nullptr_t)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* A `FunctionRef` itself is a callable as well. However, we don't want that this
|
||||
* constructor is called when `Callable` is a `FunctionRef`. If we would allow this, it
|
||||
|
|
|
@ -124,4 +124,10 @@ TEST(function_ref, CallSafeVoid)
|
|||
EXPECT_EQ(value, 1);
|
||||
}
|
||||
|
||||
TEST(function_ref, InitializeWithNull)
|
||||
{
|
||||
FunctionRef<int(int, int)> f{nullptr};
|
||||
EXPECT_FALSE(f);
|
||||
}
|
||||
|
||||
} // namespace blender::tests
|
||||
|
|
Loading…
Reference in New Issue