diff options
-rw-r--r-- | source/blender/blenlib/BLI_function_ref.hh | 4 | ||||
-rw-r--r-- | source/blender/blenlib/tests/BLI_function_ref_test.cc | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_function_ref.hh b/source/blender/blenlib/BLI_function_ref.hh index 70a064adc5d..71be7d7f029 100644 --- a/source/blender/blenlib/BLI_function_ref.hh +++ b/source/blender/blenlib/BLI_function_ref.hh @@ -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 diff --git a/source/blender/blenlib/tests/BLI_function_ref_test.cc b/source/blender/blenlib/tests/BLI_function_ref_test.cc index 74f5014142c..20c9ee5885e 100644 --- a/source/blender/blenlib/tests/BLI_function_ref_test.cc +++ b/source/blender/blenlib/tests/BLI_function_ref_test.cc @@ -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 |