From 1633c631ea66b64eb95686ec622924d3370991a5 Mon Sep 17 00:00:00 2001 From: Sadiinso <32017313+SadiinsoSnowfall@users.noreply.github.com> Date: Mon, 10 Feb 2025 18:38:37 +0100 Subject: [PATCH] Made replace_ignored a new format callable (#2061) --- include/eve/module/core/regular/replace.hpp | 101 ++++++++++---------- 1 file changed, 53 insertions(+), 48 deletions(-) diff --git a/include/eve/module/core/regular/replace.hpp b/include/eve/module/core/regular/replace.hpp index 2ea8a4e68d..a019d9423e 100644 --- a/include/eve/module/core/regular/replace.hpp +++ b/include/eve/module/core/regular/replace.hpp @@ -15,56 +15,61 @@ namespace eve { -// TODO DOC is it to be in user interface ? -//================================================================================================ -//! @addtogroup core_logical -//! @{ -//! @var replace_ignored -//! @brief A small helper to replace ignored values -//! -//! @groupheader{Header file} -//! @code -//! #include -//! @endcode -//! -//! A convinience wrapper around if_else. -//! -//! @groupheader{Callable Signatures} -//! -//! @code -//! namespace eve -//! { -//! template< eve::value T, eve::conditional_expr Ignore, eve::value Other > -//! auto replace_ignored(T x, Ignore ignore, Other with ) -//! -> decltype(eve::if_else(ignore, x, with)) -//! } -//! @endcode -//! -//! **Parameters** -//! -//! * `x` - main value -//! * `ignore` - selection -//! * `with` - value to replace with -//! -//! **Return value** -//! -//! Same as if_else. -//! -//================================================================================================ + template + struct replace_ignored_t : callable + { + template + constexpr EVE_FORCEINLINE T operator()(T x, Ignore ignore, Other with) const noexcept + { + return eve::if_else(ignore, x, with); + } -EVE_MAKE_CALLABLE(replace_ignored_, replace_ignored); + template + constexpr EVE_FORCEINLINE T operator()(T x, Ignore ignore, Other with) const noexcept + { + return eve::if_else(ignore, x, with); + } + }; -namespace detail -{ //================================================================================================ - // Helper function - Replace ignored value with an alternative + //! @addtogroup core_logical + //! @{ + //! @var replace_ignored + //! @brief A small helper to replace ignored values + //! + //! @groupheader{Header file} + //! @code + //! #include + //! @endcode + //! + //! A convinience wrapper around if_else. + //! + //! @groupheader{Callable Signatures} + //! + //! @code + //! namespace eve + //! { + //! template + //! T replace_ignored(T x, Ignore ignore, Other with); + //! + //! template + //! T replace_ignored(T x, Ignore ignore, Other with); + //! } + //! @endcode + //! + //! **Parameters** + //! + //! * `x` - main value + //! * `ignore` - selection + //! * `with` - value to replace with + //! + //! **Return value** + //! + //! Same as if_else. + //! + //================================================================================================ + inline constexpr auto replace_ignored = functor; + //================================================================================================ + //! @} //================================================================================================ - template - EVE_FORCEINLINE auto - replace_ignored_(EVE_SUPPORTS(cpu_), Wide x, Ignore ignore, Other with) noexcept - -> decltype(eve::if_else(ignore, x, with)) - { - return eve::if_else(ignore, x, with); - } -} }