Support util::function constructing from & assigning to nullptr

This commit is contained in:
Nikita Lisitsa 2024-05-20 16:41:01 +03:00
parent cae25f4719
commit 1538fa002f

View file

@ -43,11 +43,14 @@ namespace psemek::util
function() noexcept = default; function() noexcept = default;
function(std::nullptr_t) noexcept;
template <typename F> template <typename F>
function(F && f); function(F && f);
function (function &&) noexcept; function (function &&) noexcept;
function & operator = (function &&) noexcept; function & operator = (function &&) noexcept;
function & operator = (std::nullptr_t) noexcept;
function (function &) = delete; function (function &) = delete;
function (function const &) = delete; function (function const &) = delete;
@ -99,6 +102,10 @@ namespace psemek::util
void assign(F && f); void assign(F && f);
}; };
template <typename R, typename ... Args>
function<R(Args...)>::function(std::nullptr_t) noexcept
{}
template <typename R, typename ... Args> template <typename R, typename ... Args>
template <typename F> template <typename F>
function<R(Args...)>::function(F && f) function<R(Args...)>::function(F && f)
@ -148,6 +155,13 @@ namespace psemek::util
return *this; return *this;
} }
template <typename R, typename ... Args>
function<R(Args...)> & function<R(Args...)>::operator = (std::nullptr_t) noexcept
{
reset();
return *this;
}
template <typename R, typename ... Args> template <typename R, typename ... Args>
function<R(Args...)>::~function() function<R(Args...)>::~function()
{ {