Skip to content

Commit

Permalink
Fix some slight issues with latest tag_invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
jfalcou authored Aug 15, 2023
1 parent babfefc commit 920ceaa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 27 deletions.
34 changes: 16 additions & 18 deletions include/eve/traits/invoke/decorator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,18 @@ namespace eve
struct decorators : Settings
{
template <rbr::concepts::option... Options>
constexpr explicit decorators(Options && ... options) : Settings(EVE_FWD(options) ...) {}
constexpr EVE_FORCEINLINE explicit decorators(Options && ... options) : Settings(EVE_FWD(options) ...) {}

constexpr decorators(Settings const& options) : Settings(options) {}
template <typename... Options>
constexpr EVE_FORCEINLINE decorators(rbr::settings<Options...> const& options) : Settings(options) {}
};

/// Deduction guide for eve::decorators
template <rbr::concepts::option ... Options>
decorators(Options&& ... options) -> decorators<decltype(rbr::settings(EVE_FWD(options) ...))>;

template <typename... Options>
decorators(rbr::settings<Options...> const&) -> decorators<rbr::settings<Options...>>;

//================================================================================================
//! @struct support_options
//! @brief Make an eve::callable responsive to decorators and masks
Expand All @@ -88,7 +91,7 @@ namespace eve
template<typename Options>
EVE_FORCEINLINE auto operator[](Options&& o) const
{
auto new_opts = rbr::merge(rbr::settings{o}, opts);
auto new_opts = decorators{rbr::merge(rbr::settings{o}, opts)};
return fn<decltype(new_opts)>{new_opts};
}

Expand All @@ -106,9 +109,9 @@ namespace eve

template<typename... Args>
EVE_FORCEINLINE auto operator()(Args&&... x) const
-> tag_invoke_result<Tag, decorators<Settings>, Args&&...>
-> tag_invoke_result<Tag, Settings, Args&&...>
{
return eve::tag_invoke(Tag{}, decorators{opts}, EVE_FWD(x)...);
return eve::tag_invoke(Tag{}, opts, EVE_FWD(x)...);
}

template<typename... T>
Expand All @@ -120,18 +123,11 @@ namespace eve
Settings opts;
};

//! @brief Modify the semantic of current eve::callable via a bundle of decorators or masks
template<rbr::concepts::settings Settings>
EVE_FORCEINLINE auto operator[](Settings const& s) const
{
return fn<decorators<Settings>>{decorators{s}};
}

//! @brief Modify the semantic of current eve::callable by a decorator
template<rbr::concepts::option Options>
EVE_FORCEINLINE auto operator[](Options const& o) const
{
return (*this)[decorators{o}];
return fn<decltype(decorators{o})>{decorators{o}};
}

//! @brief Modify the semantic of current eve::callable by a mask
Expand Down Expand Up @@ -163,10 +159,12 @@ namespace eve
namespace eve::tags
{
template<typename S>
constexpr auto tag_invoke(deferred_callable auto tag, auto arch, decorators<S> opts, auto... x)
noexcept(noexcept(tag.deferred_call(arch, opts, x...)))
-> decltype(tag.deferred_call(arch, opts, x...))
EVE_FORCEINLINE constexpr auto tag_invoke ( deferred_callable auto tag, auto arch
, decorators<S> opts, auto&&... x
)
noexcept(noexcept(tag.deferred_call(arch, opts, EVE_FWD(x)...)))
-> decltype(tag.deferred_call(arch, opts, EVE_FWD(x)...))
{
return tag.deferred_call(arch, opts, x...);
return tag.deferred_call(arch, opts, EVE_FWD(x)...);
}
}
24 changes: 15 additions & 9 deletions include/eve/traits/invoke/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//====================================================================================================
#pragma once

#include "eve/detail/raberu.hpp"
#include <eve/detail/raberu.hpp>
#include <eve/arch/spec.hpp>
#include <eve/traits/invoke/tag_invoke.hpp>

Expand All @@ -30,7 +30,9 @@ namespace eve
//==================================================================================================
template<typename Signature>
struct unsupported_call
{};
{
constexpr operator bool() const noexcept { return false; }
};

//! @brief Tag type for elementwise @callable properties
struct elementwise
Expand Down Expand Up @@ -132,18 +134,22 @@ std::ostream& operator<<(std::ostream& os, Tag const&)
//==================================================================================================
namespace eve::tags
{
constexpr auto tag_invoke(deferred_callable auto tag, auto arch, auto... x)
noexcept(noexcept(tag.deferred_call(arch, x...))) -> decltype(tag.deferred_call(arch, x...))
template<deferred_callable Tag>
EVE_FORCEINLINE constexpr auto tag_invoke(Tag, auto arch, auto&&... x)
noexcept(noexcept(Tag::deferred_call(arch, EVE_FWD(x)...)))
-> decltype(Tag::deferred_call(arch, EVE_FWD(x)...))
{
return tag.deferred_call(arch, x...);
return Tag::deferred_call(arch, EVE_FWD(x)...);
}
}

#define EVE_DEFERRED_INVOKE() \
constexpr auto tag_invoke(eve::deferred_callable auto tag, auto arch, auto... x) \
noexcept(noexcept(tag.deferred_call(arch, x...))) -> decltype(tag.deferred_call(arch, x...)) \
template<eve::deferred_callable Tag> \
EVE_FORCEINLINE constexpr auto tag_invoke(Tag, auto arch, auto&&... x) \
noexcept(noexcept(Tag::deferred_call(arch, EVE_FWD(x)...))) \
-> decltype(Tag::deferred_call(arch, EVE_FWD(x)...)) \
{ \
return tag.deferred_call(arch, x...); \
return Tag::deferred_call(arch, EVE_FWD(x)...); \
} \
/**/

Expand Down Expand Up @@ -188,7 +194,7 @@ namespace eve::detail
// General macro taking the deferred namespace NS and the function NAME
//==================================================================================================
#define EVE_DEFERS_CALLABLE_FROM(NS,NAME) \
static auto deferred_call(auto arch, auto&&...args) noexcept \
static EVE_FORCEINLINE auto deferred_call(auto arch, auto&&...args) noexcept \
-> decltype(NAME(NS::adl_delay, arch, EVE_FWD(args)...)) \
{ \
return NAME(NS::adl_delay, arch, EVE_FWD(args)...); \
Expand Down

0 comments on commit 920ceaa

Please sign in to comment.