From 1538fa002fe7f2e3d126559b7fc062c86a24a37d Mon Sep 17 00:00:00 2001 From: lisyarus Date: Mon, 20 May 2024 16:41:01 +0300 Subject: [PATCH] Support util::function constructing from & assigning to nullptr --- libs/util/include/psemek/util/function.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libs/util/include/psemek/util/function.hpp b/libs/util/include/psemek/util/function.hpp index 42d4cc6b..4da1b449 100644 --- a/libs/util/include/psemek/util/function.hpp +++ b/libs/util/include/psemek/util/function.hpp @@ -43,11 +43,14 @@ namespace psemek::util function() noexcept = default; + function(std::nullptr_t) noexcept; + template function(F && f); function (function &&) noexcept; function & operator = (function &&) noexcept; + function & operator = (std::nullptr_t) noexcept; function (function &) = delete; function (function const &) = delete; @@ -99,6 +102,10 @@ namespace psemek::util void assign(F && f); }; + template + function::function(std::nullptr_t) noexcept + {} + template template function::function(F && f) @@ -148,6 +155,13 @@ namespace psemek::util return *this; } + template + function & function::operator = (std::nullptr_t) noexcept + { + reset(); + return *this; + } + template function::~function() {