diff --git a/include/tl/function_ref.hpp b/include/tl/function_ref.hpp index 4b90dbf..fdd86f5 100644 --- a/include/tl/function_ref.hpp +++ b/include/tl/function_ref.hpp @@ -167,8 +167,9 @@ template class function_ref { /// /// \synopsis template constexpr function_ref &operator=(F &&f) noexcept; template ::value> - * = nullptr> + detail::fnref::enable_if_t< + !std::is_same, function_ref>::value && + detail::fnref::is_invocable_r::value> * = nullptr> TL_FUNCTION_REF_11_CONSTEXPR function_ref &operator=(F &&f) noexcept { obj_ = reinterpret_cast(std::addressof(f)); callback_ = [](void *obj, Args... args) { diff --git a/tests/assignment.cpp b/tests/assignment.cpp index 9673a6c..9cee22a 100644 --- a/tests/assignment.cpp +++ b/tests/assignment.cpp @@ -1,5 +1,6 @@ #include "catch.hpp" #include +#include void f(){} struct b { @@ -18,3 +19,8 @@ TEST_CASE("Assignment", "[assignment]") { fr = &b::qux; } } + +using FR = tl::function_ref; +static_assert(std::is_trivially_assignable::value, ""); +static_assert(std::is_trivially_assignable::value, ""); +static_assert(std::is_trivially_assignable::value, ""); diff --git a/tests/constructors.cpp b/tests/constructors.cpp index 1d0a304..abc89fc 100644 --- a/tests/constructors.cpp +++ b/tests/constructors.cpp @@ -1,5 +1,6 @@ #include "catch.hpp" #include +#include void foo(){} struct bar { @@ -16,3 +17,8 @@ TEST_CASE("Constructors", "[constructors]") { (void)fr2; (void)fr3; } + +using FR = tl::function_ref; +static_assert(std::is_trivially_constructible::value, ""); +static_assert(std::is_trivially_constructible::value, ""); +static_assert(std::is_trivially_constructible::value, "");