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

Add is_specialization_of type trait #3338

Merged
merged 2 commits into from
Sep 4, 2020

Conversation

dhollman
Copy link

@dhollman dhollman commented Sep 3, 2020

Adding useful type trait that can be leveraged a number of places in SFINAE.

It would also in principle allow to replace code like

template <class>
struct is_view : public std::false_type {};
template <class D, class... P>
struct is_view<View<D, P...>> : public std::true_type {};
template <class D, class... P>
struct is_view<const View<D, P...>> : public std::true_type {};

by

template <class T>
struct is_view : Impl::is_specialization_of<std::remove_cv_t<T>, View>::type {};

One limitation is it won't compile if you pass a template such as Kokkos::Array as its second argument or any template that has a non-type template parameter.

@crtrott
Copy link
Member

crtrott commented Sep 3, 2020

This link seems to have the arguments the other way around:
https://stackoverflow.com/questions/12919310/c-detect-templated-class
? What is the right way and why?

NVM: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2098r0.pdf has it the same way as you so that is good.

dalg24
dalg24 previously requested changes Sep 3, 2020
Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

You must add compile-time unit test.

@dalg24 dalg24 dismissed their stale review September 4, 2020 00:55

Test was added

@dalg24 dalg24 changed the title Graph Prototype Stage 1: is_specialization_of Add is_specialization_of type trait Sep 4, 2020
@dalg24 dalg24 merged commit 53adf13 into kokkos:develop Sep 4, 2020
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.

None yet

3 participants