Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better overload #1679

Merged
merged 28 commits into from
Nov 18, 2023
Merged

Better overload #1679

merged 28 commits into from
Nov 18, 2023

Conversation

jfalcou
Copy link
Owner

@jfalcou jfalcou commented Sep 21, 2023

After some more discussions, this implements a 3rd version of our overload system.

include/eve/traits/overload/default_behaviors.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/default_behaviors.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/protocol.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/protocol.hpp Show resolved Hide resolved
include/eve/traits/overload/supports.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/supports.hpp Outdated Show resolved Hide resolved
test/doc/traits/callable_constant.cpp Show resolved Hide resolved
test/doc/traits/callable_object.cpp Outdated Show resolved Hide resolved
test/doc/traits/callable_specs.cpp Outdated Show resolved Hide resolved
@DenisYaroshevskiy
Copy link
Collaborator

FYI, this how I'd like "supports" to look


struct conditional_relative_in_out {
  template <rbr::concepts::settings Settings>
  EVE_FORCEINLINE
  static constexpr auto process_option(options<Settings> opt, eve::relative_conditional_expr auto ignore) 
  {
     if constexpr ( Settings::contains(out_ignore) ) { static_assert("Only supports 'in' and 'out' ignore"); }
     else if constexpr ( Settings::contains(in_ignore) ) { return default_to( opt, options(out_ignore = ignore) ); }
     else return default_to( opt, options(in_ignore = ignore) ); }
  }

  template <rbr::concepts::settings Settings>
  EVE_FORCEINLINE
  static constexpr auto defaults(options<Settings> opt) 
  {
     auto in = default_to(opt, options(in_ignore = ignore_none);
     return default_to(in, options(out_ignore = in[in_ignore]);
  }
};

@jfalcou
Copy link
Owner Author

jfalcou commented Sep 22, 2023

FYI, this how I'd like "supports" to look


struct conditional_relative_in_out {
  template <rbr::concepts::settings Settings>
  EVE_FORCEINLINE
  static constexpr auto process_option(options<Settings> opt, eve::relative_conditional_expr auto ignore) 
  {
     if constexpr ( Settings::contains(out_ignore) ) { static_assert("Only supports 'in' and 'out' ignore"); }
     else if constexpr ( Settings::contains(in_ignore) ) { return default_to( opt, options(out_ignore = ignore) ); }
     else return default_to( opt, options(in_ignore = ignore) ); }
  }

  template <rbr::concepts::settings Settings>
  EVE_FORCEINLINE
  static constexpr auto defaults(options<Settings> opt) 
  {
     auto in = default_to(opt, options(in_ignore = ignore_none);
     return default_to(in, options(out_ignore = in[in_ignore]);
  }
};

what's default_to here ?

@DenisYaroshevskiy
Copy link
Collaborator

what's default_to here ?

options{rbr::merge(op, defaults)};

@jfalcou jfalcou force-pushed the feat/better-overload branch from bbc60af to d08f867 Compare October 3, 2023 19:16
@jfalcou jfalcou force-pushed the feat/better-overload branch 3 times, most recently from 549bc97 to cb9e54f Compare October 13, 2023 20:39
@jfalcou
Copy link
Owner Author

jfalcou commented Oct 13, 2023

Applied most of the discussed changes.
Names etc still open if you want to have a 2nd go

include/eve/traits/overload/default_behaviors.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/protocol.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/protocol.hpp Show resolved Hide resolved
include/eve/traits/overload/supports.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/supports.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/supports.hpp Show resolved Hide resolved
include/eve/traits/overload/supports.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/supports.hpp Outdated Show resolved Hide resolved
test/doc/traits/callable_specs.cpp Show resolved Hide resolved
include/eve/traits/overload/protocol.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/protocol.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/protocol.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/protocol.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/default_behaviors.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/protocol.hpp Show resolved Hide resolved
include/eve/traits/overload/supports.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/supports.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/supports.hpp Show resolved Hide resolved
include/eve/traits/overload/default_behaviors.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/default_behaviors.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/supports.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/supports.hpp Outdated Show resolved Hide resolved

/// Default settings of eve::conditional is eve::ignore_none
EVE_FORCEINLINE static constexpr auto defaults() noexcept { return options{condition_key = ignore_none}; }
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, do we want to just inherit relative_condition_option?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about it but wasn't sure.

test/doc/traits/callable_object.cpp Outdated Show resolved Hide resolved
test/doc/traits/callable_specs.cpp Outdated Show resolved Hide resolved
test/doc/traits/callable_specs.cpp Show resolved Hide resolved
@jfalcou jfalcou force-pushed the feat/better-overload branch from 0144458 to 14a7d0a Compare November 12, 2023 14:06
include/eve/traits/overload/default_behaviors.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/default_behaviors.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/default_behaviors.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/default_behaviors.hpp Outdated Show resolved Hide resolved
test/doc/traits/callable_object.cpp Outdated Show resolved Hide resolved
test/doc/traits/callable_object_from.cpp Outdated Show resolved Hide resolved
test/doc/traits/callable_specs.cpp Outdated Show resolved Hide resolved
test/doc/traits/callable_supports.cpp Outdated Show resolved Hide resolved
test/doc/traits/callable_supports.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@DenisYaroshevskiy DenisYaroshevskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will look more

include/eve/traits/overload/default_behaviors.hpp Outdated Show resolved Hide resolved
include/eve/traits/overload/supports.hpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@DenisYaroshevskiy DenisYaroshevskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will approve. I don't think we quite understand everything yet and there are some flaws I am seeing, but they need expirience

include/eve/traits/invoke/protocol.hpp Show resolved Hide resolved
auto const f = Func<decltype(rmv_cond)>{rmv_cond};

// If the conditional call is supported, call it
if constexpr( is_supported ) return detail::mask_op(cond, f, x0, xs...);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if I understand how you plan to support conditionals.

You say is_supported for a conditional call. What would that spec look like?

Alternatively - it should always be supported and this just keeps being in all overloads.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup this is fishy, removign elementwise for now as discussed

constexpr bool any_simd = (simd_value<T> || ... || simd_value<Ts>);

// Are we dealing with a no-condition call ?
if constexpr( option_type_is<condition_key, O, ignore_none_> )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Ignore all support?

Do we have a uniform logic on how we handle ignores in element wise?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bit lacking indeed

@jfalcou jfalcou merged commit 9c9e7e3 into main Nov 18, 2023
35 checks passed
@jfalcou jfalcou deleted the feat/better-overload branch November 18, 2023 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants