Skip to content

CPP20Hackathon: Add more concepts and use them in pattern/forall#2012

Open
MrBurmark wants to merge 1 commit into
feature/bowen/cpp-20-hackathonfrom
feature/burmark1/more_forall_concepts
Open

CPP20Hackathon: Add more concepts and use them in pattern/forall#2012
MrBurmark wants to merge 1 commit into
feature/bowen/cpp-20-hackathonfrom
feature/burmark1/more_forall_concepts

Conversation

@MrBurmark

Copy link
Copy Markdown
Member

I tried to conceptify the remaining types in the pattern forall interface.

I notice that the RAJA::Resource concept is close to overlapping with camp::resources::Resource.
The RAJA::Resource concept seems to be more of a typed resource concept and does not seem to include camp::resources::Resource. We may want to consider renaming for clarity.

Some of the concepts that I added, like PotentiallyInvokable or NonResource, are vague but may still be useful to document the types that we are intended to be passed through some functions.

@MrBurmark MrBurmark requested review from artv3 and johnbowen42 April 14, 2026 16:57
union U{};
using L = decltype([]{});
static_assert(!PotentialInvokable<I>);
static_assert(!PotentialInvokable<I&>);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you make a variadic template that tries to substitute the pack into std::is_invocable?

{
/// Adapter to replace specific implementations for the icount variants
template<typename Range, typename Body, typename IndexT>
template<Range Container, PotentialInvokable Body, IndexTypeConcept IndexT>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We might want to review what concretely we care about in term of Body. I think we might something conceptually much narrower than Invocable

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree with that. Also, it seems like the PotentialInvokable name is somewhat confusing (vs. Invokable which may be a requirement we want to enforce). If the Body arg is NOT invokable, what does that mean?

Range Container,
typename LoopBody,
typename Res = typename resources::get_resource<ExecutionPolicy>::type>
PotentialInvokable Body,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we want to create a concept for lambdas for external, user facing function templates, and then another Privatizer based concept for internal calls

using container_type = typename std::decay<Range>::type;
using container_type = typename std::decay<Container>::type;
typename container_type::iterator begin_it;
Index_type icount;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Index_type icount;
index_type icount;

outside of this PR, but line 100 defines using index_type = typename std::decay<IndexT>::type; are we using the right one?

using index_type = typename std::decay<IndexT>::type;
typename std::decay<Body>::type body;
using container_type = typename std::decay<Range>::type;
using container_type = typename std::decay<Container>::type;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
using container_type = typename std::decay<Container>::type;
using container_type = std::decay_t<Container>;

More compact

template<Range Container, PotentialInvokable Body, IndexTypeConcept IndexT>
struct icount_adapter
{
using index_type = typename std::decay<IndexT>::type;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
using index_type = typename std::decay<IndexT>::type;
using index_type = std::decay_t<IndexT>;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@artv3 I think this sort of thing is now your favorite type of PR review comment 😆

template < typename B >
concept PotentialInvokable =
std::is_class_v<std::remove_cvref_t<B>> ||
std::is_union_v<std::remove_cvref_t<B>> ||

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we have callable unions in our applications?

@johnbowen42 johnbowen42 added this to the June 2026 Release milestone May 5, 2026
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.

5 participants