diff --git a/Source/Core/Common/Functional.h b/Source/Core/Common/Functional.h index 49d81d5a243..cdb44ebb0c0 100644 --- a/Source/Core/Common/Functional.h +++ b/Source/Core/Common/Functional.h @@ -3,7 +3,9 @@ #pragma once +#include #include +#include // TODO C++23: Replace with std::move_only_function. @@ -21,13 +23,14 @@ public: MoveOnlyFunction() = default; - template + template F> + requires(!std::same_as, MoveOnlyFunction>) MoveOnlyFunction(F&& f) : m_ptr{std::make_unique>(std::forward(f))} { } result_type operator()(Args... args) const { return m_ptr->Invoke(std::forward(args)...); } - explicit operator bool() const { return m_ptr != nullptr; }; + explicit operator bool() const { return m_ptr != nullptr; } void swap(MoveOnlyFunction& other) { m_ptr.swap(other.m_ptr); } private: @@ -40,9 +43,9 @@ private: template struct Func : FuncBase { - Func(F&& f) : func{std::forward(f)} {} + explicit Func(F&& f) : func{std::forward(f)} {} result_type Invoke(Args... args) override { return func(std::forward(args)...); } - F func; + std::decay_t func; }; std::unique_ptr m_ptr;