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

Switch to using invoke_result_t #939

Merged
merged 1 commit into from
Sep 18, 2023
Merged

Conversation

aprokop
Copy link
Contributor

@aprokop aprokop commented Aug 26, 2023

We have few places that use a combination of decltype and declval that could be simplified by using invoke_result_t (available starting c++17).

@aprokop aprokop added the refactoring Code reorganization label Aug 26, 2023
Copy link
Contributor

@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.

What about

template <class V>
using deduce_point_t =
decltype(ArborX::AccessTraits<V, ArborX::PrimitivesTag>::get(
std::declval<V>(), 0));

using size_type = decltype(Access::size(std::declval<Points const &>()));

decltype(Kokkos::create_mirror_view(Kokkos::HostSpace{},
std::declval<LabelsView>()))

using T = std::decay_t<decltype(Access::get(
std::declval<Predicates const &>(), std::declval<int>()))>;

using Geometry =
std::decay_t<decltype(getGeometry(std::declval<Predicate const &>()))>;

using size_type = decltype(Access::size(std::declval<Predicates const &>()));

using DestBufferMirrorViewType =
decltype(ArborX::Details::create_layout_right_mirror_view_and_copy(
space, std::declval<typename ImportView::memory_space>(),
std::declval<ExportViewWithoutMemoryTraits>()));

@aprokop
Copy link
Contributor Author

aprokop commented Aug 28, 2023

What about

I tried those (other than mirror views, those are different as they don't invoke anything), and they seem brittle and depend on compiler. Things like

 using size_type = decltype(Access::size(std::declval<Predicates const &>()));

sometimes worked as

using size_type = std::invoke_result_of<Access::size, Predicates>;

sometimes as

using size_type = std::invoke_result_of<decltype(Access::size), Predicates>;

and sometimes didn't. Access::get was the worst. See these build failures.

So I limited this PR only to the absolutely straightforward cases.

@aprokop
Copy link
Contributor Author

aprokop commented Aug 28, 2023

Rebased on master to take use #937.

@aprokop
Copy link
Contributor Author

aprokop commented Aug 28, 2023

Couple builds failed due to disk space (SYCL and one of the CUDA). Otherwise, good. @dalg24 Do you have any reservations about merging this one?

Copy link
Contributor

@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.

Unfortunate that we mix style going forward but sure fine

@aprokop
Copy link
Contributor Author

aprokop commented Sep 11, 2023

Rebased on master.

@aprokop
Copy link
Contributor Author

aprokop commented Sep 18, 2023

HIP did not run, all others passed. Merging.

@aprokop aprokop merged commit 3f8fbc9 into arborx:master Sep 18, 2023
1 check passed
@aprokop aprokop deleted the invoke_result_t branch September 18, 2023 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code reorganization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants