From 40e1c55caacae8ce7bc89d83f9192bb48ad95e59 Mon Sep 17 00:00:00 2001 From: Joel Falcou Date: Sun, 15 Oct 2023 16:48:54 +0200 Subject: [PATCH] More fixes from Dennis' remarks --- .../eve/traits/overload/default_behaviors.hpp | 8 +++- include/eve/traits/overload/protocol.hpp | 42 ++++++++++++------- include/eve/traits/overload/supports.hpp | 42 ++++++++++++++++--- test/doc/traits/callable_supports.cpp | 4 +- 4 files changed, 72 insertions(+), 24 deletions(-) diff --git a/include/eve/traits/overload/default_behaviors.hpp b/include/eve/traits/overload/default_behaviors.hpp index 778387a39af..33bb1a4232a 100644 --- a/include/eve/traits/overload/default_behaviors.hpp +++ b/include/eve/traits/overload/default_behaviors.hpp @@ -72,6 +72,12 @@ namespace eve //! @struct constant //! @brief CRTP base class giving an eve::callable the constant function semantic //! + //! **Defined in Header** + //! + //! @code + //! #include + //! @endcode + //! //! Constants functions in EVE are built using a very common pattern. Inheriting from eve::constant simplifies the //! implementation of such eve::callable by just requiring your eve::callable type to implement a static `value` //! member function that provides the constant value using two parameters: @@ -89,7 +95,7 @@ namespace eve //! @godbolt{doc/traits/callable_constant.cpp} //! @} //==================================================================================================================== - template struct constant : supports + template struct constant : supports { struct behavior { diff --git a/include/eve/traits/overload/protocol.hpp b/include/eve/traits/overload/protocol.hpp index 448d28f3e21..96359e8dfe8 100644 --- a/include/eve/traits/overload/protocol.hpp +++ b/include/eve/traits/overload/protocol.hpp @@ -26,6 +26,12 @@ namespace eve //! @concept callable //! @brief **EVE** callable //! + //! **Defined in Header** + //! + //! @code + //! #include + //! @endcode + //! //! A type `T` satisfies eve::callable if and only if it is tagged as such manually. //! //! @tparam T T type for the @callable to check @@ -41,6 +47,12 @@ namespace eve //! @def EVE_CALLABLE_OBJECT_FROM //! @brief Generate the generic function interface for any EVE-compatible @callable //! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! //! Use inside a @callable definition to generate the required EVE protocol of function's resolution based on type //! and architecture informations. //! @@ -76,16 +88,13 @@ requires( requires { std::declval().call(EVE_FWD(args)...); }) { \ return TYPE::deferred_call(eve::current_api, eve::detail::defaults(), EVE_FWD(args)...); \ } \ -static EVE_FORCEINLINE decltype(auto) deferred_call(auto arch, auto&&...args) noexcept \ -requires(requires { NAME(NS::adl_helper, arch, EVE_FWD(args)...); }) \ -{ \ - return NAME(NS::adl_helper, arch, EVE_FWD(args)...); \ -} \ template \ static EVE_FORCEINLINE decltype(auto) deferred_call(auto arch, Args&&...args) noexcept \ -requires(!requires { NAME(NS::adl_helper, arch, EVE_FWD(args)...); }) \ { \ - return eve::detail::default_behavior::call(arch, EVE_FWD(args)...); \ + if constexpr( requires { NAME(NS::adl_helper, arch, EVE_FWD(args)...); } ) \ + return NAME(NS::adl_helper, arch, EVE_FWD(args)...); \ + else \ + return eve::detail::default_behavior::call(arch, EVE_FWD(args)...); \ } \ using callable_tag_type = TYPE \ /**/ @@ -96,6 +105,12 @@ using callable_tag_type = TYPE //! @def EVE_CALLABLE_OBJECT //! @brief Generate the generic function interface for an actual eve::callable //! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! //! Use inside a @callable definition to generate the required EVE protocol of function's resolution based on type //! and architecture informations using overload from the `eve::detail` namespace. //! @@ -130,16 +145,13 @@ requires( requires { std::declval().call(EVE_FWD(args)...); }) { \ return TYPE::deferred_call(eve::current_api, eve::detail::defaults(), EVE_FWD(args)...); \ } \ -static EVE_FORCEINLINE decltype(auto) deferred_call(auto arch, auto&&...args) noexcept \ -requires(requires { NAME(eve::detail::adl_helper, arch, EVE_FWD(args)...); }) \ -{ \ - return NAME(eve::detail::adl_helper, arch, EVE_FWD(args)...); \ -} \ template \ static EVE_FORCEINLINE decltype(auto) deferred_call(auto arch, Args&&...args) noexcept \ -requires(!requires { NAME(eve::detail::adl_helper, arch, EVE_FWD(args)...); }) \ { \ - return eve::detail::default_behavior::call(arch, EVE_FWD(args)...); \ + if constexpr( requires { NAME(eve::detail::adl_helper, arch, EVE_FWD(args)...); } ) \ + return NAME(eve::detail::adl_helper, arch, EVE_FWD(args)...); \ + else \ + return eve::detail::default_behavior::call(arch, EVE_FWD(args)...); \ } \ using callable_tag_type = TYPE \ /**/ @@ -156,7 +168,7 @@ struct adl_helper_t {}; inline constexpr auto adl_helper = adl_helper_t {} \ /**/ -// Flag a function to support delayed calls on given architecture +/// Flag a function to support delayed calls on given architecture #define EVE_REQUIRES(ARCH) adl_helper_t const &, ARCH const & // Register eve::detail as the deferred namespace by default diff --git a/include/eve/traits/overload/supports.hpp b/include/eve/traits/overload/supports.hpp index 42421999ed0..a92719d84fe 100644 --- a/include/eve/traits/overload/supports.hpp +++ b/include/eve/traits/overload/supports.hpp @@ -19,6 +19,12 @@ namespace eve //! @struct options //! @brief Wrapper class around bundle of options passed to eve::callable //! + //! **Defined in Header** + //! + //! @code + //! #include + //! @endcode + //! //! eve::callable can be decorated with options. eve::options is used internally to gather all those options //! in a @raberu settings instance for further processing. //! @@ -90,6 +96,12 @@ namespace eve //! @var condition_key //! @brief Keyword for retrieving conditionals decorator //! + //! **Defined in Header** + //! + //! @code + //! #include + //! @endcode + //! //! When a eve::decorated_callable is called with an option provided via eve::conditional, the value of the //! conditional can be retrieved using eve::condition_key //! @see eve::supports @@ -144,6 +156,12 @@ namespace eve //! @struct supports //! @brief Helper class to aggregate options handlers //! + //! **Defined in Header** + //! + //! @code + //! #include + //! @endcode + //! //! eve::callable can be decorated with options. eve::supports is used to list all subset of options a given EVE //! @callable is allowed to support and to handle the default values of such subsets. //! @@ -197,10 +215,16 @@ namespace eve //==================================================================================================================== //! @addtogroup extensions //! @{ - //! @struct conditional_options + //! @struct conditional_option //! @brief Option specification for decoration via conditional value and expressions //! - //! eve::conditional_options is an option specification that can be used when defining a eve::callable type to make + //! **Defined in Header** + //! + //! @code + //! #include + //! @endcode + //! + //! eve::conditional_option is an option specification that can be used when defining a eve::callable type to make //! it supports decoration via `bool`, eve::logical, any eve::conditional_expr or eve::relative_conditional_expr. //! //! @groupheader{Example} @@ -208,7 +232,7 @@ namespace eve //! @godbolt{doc/traits/callable_supports.cpp} //! @} //==================================================================================================================== - struct conditional_options + struct conditional_option { auto process_option(auto const& base, rbr::concepts::exactly auto opt) const { @@ -240,10 +264,16 @@ namespace eve //==================================================================================================================== //! @addtogroup extensions //! @{ - //! @struct relative_conditional_options + //! @struct relative_conditional_option //! @brief Option specification for decoration via relative conditional value and expressions //! - //! eve::relative_conditional_options is an option specification that can be used when defining a eve::callable + //! **Defined in Header** + //! + //! @code + //! #include + //! @endcode + //! + //! eve::relative_conditional_option is an option specification that can be used when defining a eve::callable //! type to make it supports decoration via any eve::relative_conditional_expr. //! //! @groupheader{Example} @@ -251,7 +281,7 @@ namespace eve //! @godbolt{doc/traits/callable_supports.cpp} //! @} //==================================================================================================================== - struct relative_conditional_options + struct relative_conditional_option { auto process_option(auto const& base, eve::relative_conditional_expr auto opt) const { diff --git a/test/doc/traits/callable_supports.cpp b/test/doc/traits/callable_supports.cpp index be5ea59b265..07875942009 100644 --- a/test/doc/traits/callable_supports.cpp +++ b/test/doc/traits/callable_supports.cpp @@ -8,14 +8,14 @@ namespace eve { // + supports give rules for decorator to use on a given callable and a default set of options // + eve::conditional give the ability to pass a mask as a decoration. - struct func_t : supports + struct func_t : supports { // Note that decoration doesn't impact signature declaration template auto call(T const&) -> T; EVE_CALLABLE_OBJECT(func_t, func_); } inline constexpr func; - struct other_func_t : supports + struct other_func_t : supports { // Note that decoration doesn't impact signature declaration template auto call(T const&) -> T;