From 5eb1b523d6d7591682cdc0c55a2072eb1064b535 Mon Sep 17 00:00:00 2001 From: Kim-J-Smith <3440910457@qq.com> Date: Fri, 5 Jun 2026 22:00:17 +0800 Subject: [PATCH 1/3] refactor: refactor `is_callable_from` and `is_invocable_using`. --- include/embed/embed_function.hpp | 34 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/include/embed/embed_function.hpp b/include/embed/embed_function.hpp index a16294b..4dabdbf 100644 --- a/include/embed/embed_function.hpp +++ b/include/embed/embed_function.hpp @@ -1086,7 +1086,7 @@ inline namespace fn_traits { // Check the functor is callable with given arguments. // [func.wrap.move.ctor]/1 template - struct is_callable_from { + struct is_callable_from_impl { using unwrap_sig = unwrap_signature; using ret = typename unwrap_sig::ret; using args_pack = typename unwrap_sig::args; @@ -1549,7 +1549,8 @@ inline namespace fn_traits { #endif // . - template ::pure_sig> struct is_invocable_using_impl; template @@ -1561,11 +1562,6 @@ inline namespace fn_traits { >; }; - // [func.wrap.ref.ctor]/1 is-invokable-using - template - using is_invocable_using_t = - typename is_invocable_using_impl>::type; - template struct is_constant_wrapper : std::false_type {}; @@ -2695,6 +2691,14 @@ namespace crtp_mixins { // `true` if self is copyable. static constexpr bool internal_is_copyable = Config::isCopyable || Config::isView; + // [func.wrap.move.ctor]/1 is-callable-from + template + using is_callable_from = is_callable_from_impl; + + // [func.wrap.ref.ctor]/1 is-invocable-using + template + using is_invocable_using = is_invocable_using_impl>; + public: // The return type. @@ -2807,7 +2811,7 @@ namespace crtp_mixins { (!fn_can_convert::value) && (!is_self::value) && (!is_in_place_type>::value) - && is_callable_from::value + && is_callable_from::value && (!Config::isView) ) function(Functor&& functor) noexcept(is_nothrow_construct_from_functor::value) { @@ -2829,7 +2833,7 @@ namespace crtp_mixins { EMBED_DETAIL_TEMPLATE_BEGIN(typename Func) EMBED_DETAIL_REQUIRES_END( std::is_function::value - && is_invocable_using_t::value + && is_invocable_using::value && Config::isView ) function(Func* function_ptr) noexcept { @@ -2853,7 +2857,7 @@ namespace crtp_mixins { typename Tp_cv = typename unwrap_signature::template add_cv_like) EMBED_DETAIL_REQUIRES_END( (!is_self::value) - && is_invocable_using_t::value + && is_invocable_using::value && (!std::is_member_pointer::value) && (!fn_can_convert::value) && Config::isView @@ -2875,7 +2879,7 @@ namespace crtp_mixins { EMBED_DETAIL_TEMPLATE_BEGIN(typename Fn, typename... CArgs) EMBED_DETAIL_REQUIRES_END( std::is_constructible::value - && is_callable_from::value + && is_callable_from::value && (!Config::isView) ) explicit function(std::in_place_type_t, CArgs&&... args) noexcept(std::is_nothrow_constructible::value) { @@ -2895,7 +2899,7 @@ namespace crtp_mixins { EMBED_DETAIL_TEMPLATE_BEGIN(typename Fn, typename U, typename... CArgs) EMBED_DETAIL_REQUIRES_END( std::is_constructible&, CArgs...>::value - && is_callable_from::value + && is_callable_from::value && (!Config::isView) ) explicit function(std::in_place_type_t, std::initializer_list il, CArgs&&... args) noexcept(std::is_nothrow_constructible::value) { @@ -2917,7 +2921,7 @@ namespace crtp_mixins { // Create function reference with given `std::constant_wrapper` param. template - requires is_invocable_using_t::value + requires is_invocable_using::value && Config::isView constexpr function(std::constant_wrapper) noexcept : MemberVariableBase(nullptr) { @@ -2933,7 +2937,7 @@ namespace crtp_mixins { // Create function reference with given `std::constant_wrapper` and object params. template > requires (!std::is_rvalue_reference_v) - && is_invocable_using_t::template add_cv_like&>::value && Config::isView constexpr function(std::constant_wrapper, Up&& obj) noexcept @@ -2952,7 +2956,7 @@ namespace crtp_mixins { typename Tp_cv = typename unwrap_signature::template add_cv_like > requires std::is_convertible_v - && is_invocable_using_t::value + && is_invocable_using::value && Config::isView constexpr function(std::constant_wrapper, Tp* obj) noexcept : MemberVariableBase(nullptr) { From acde3cad71fb3e0464d12bdca695fa92d3679705 Mon Sep 17 00:00:00 2001 From: Kim-J-Smith <3440910457@qq.com> Date: Fri, 5 Jun 2026 22:08:00 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20fix=20bug=20in=20error=20"=E2=80=98v?= =?UTF-8?q?alue=E2=80=99=20is=20not=20a=20member=20of=20=E2=80=98ebd::deta?= =?UTF-8?q?il::fn=5Ftraits::is=5Finvocable=5Fusing=5Fimpl,=20int()>=E2=80=99".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/embed/embed_function.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/embed/embed_function.hpp b/include/embed/embed_function.hpp index 4dabdbf..df388d6 100644 --- a/include/embed/embed_function.hpp +++ b/include/embed/embed_function.hpp @@ -1554,13 +1554,13 @@ inline namespace fn_traits { typename PureSig = typename unwrap_signature::pure_sig> struct is_invocable_using_impl; template - struct is_invocable_using_impl, Ret(Args...)> { - using type = conditional_t< + struct is_invocable_using_impl, Ret(Args...)> + : conditional_t< unwrap_signature::isNoexcept, is_nothrow_invocable_r, is_invocable_r - >; - }; + > + {}; template struct is_constant_wrapper : std::false_type {}; From 91effe877378122e419828d7a36f1a5d148ceaac Mon Sep 17 00:00:00 2001 From: Kim-J-Smith <3440910457@qq.com> Date: Fri, 5 Jun 2026 22:16:20 +0800 Subject: [PATCH 3/3] feat: simplify `typename unwrap_signature::template add_cv_like` as `add_cv_like_sig_t`. --- include/embed/embed_function.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/embed/embed_function.hpp b/include/embed/embed_function.hpp index df388d6..9be831a 100644 --- a/include/embed/embed_function.hpp +++ b/include/embed/embed_function.hpp @@ -2699,6 +2699,9 @@ namespace crtp_mixins { template using is_invocable_using = is_invocable_using_impl>; + template + using add_cv_like_sig_t = typename unwrap_signature::template add_cv_like; + public: // The return type. @@ -2854,7 +2857,7 @@ namespace crtp_mixins { /// @note Used for function reference only. (NON-OWNING) EMBED_DETAIL_TEMPLATE_BEGIN(typename Functor, typename Tp = remove_reference_t, - typename Tp_cv = typename unwrap_signature::template add_cv_like) + typename Tp_cv = add_cv_like_sig_t) EMBED_DETAIL_REQUIRES_END( (!is_self::value) && is_invocable_using::value @@ -2937,8 +2940,7 @@ namespace crtp_mixins { // Create function reference with given `std::constant_wrapper` and object params. template > requires (!std::is_rvalue_reference_v) - && is_invocable_using::template add_cv_like&>::value + && is_invocable_using&>::value && Config::isView constexpr function(std::constant_wrapper, Up&& obj) noexcept : MemberVariableBase(nullptr) { @@ -2952,9 +2954,7 @@ namespace crtp_mixins { } // Create function reference with given `std::constant_wrapper` and pointer params. - template ::template add_cv_like - > + template > requires std::is_convertible_v && is_invocable_using::value && Config::isView