From 43a55fdef6f28c653ebad90d85204038ec6c9c14 Mon Sep 17 00:00:00 2001 From: Andrey Prokopenko Date: Fri, 11 Oct 2024 06:50:52 -0400 Subject: [PATCH] Fix getGeometry for prvalues If a passed function argument is a prvalue, it will be destroyed once we return, as returning a reference to its member does not extend its lifetime. --- src/spatial/detail/ArborX_Predicates.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/spatial/detail/ArborX_Predicates.hpp b/src/spatial/detail/ArborX_Predicates.hpp index 5c3ca6941..df3180bd6 100644 --- a/src/spatial/detail/ArborX_Predicates.hpp +++ b/src/spatial/detail/ArborX_Predicates.hpp @@ -147,6 +147,11 @@ getGeometry(Nearest const &pred) { return pred._geometry; } +template +KOKKOS_INLINE_FUNCTION Geometry getGeometry(Nearest &&pred) +{ + return pred._geometry; +} template KOKKOS_INLINE_FUNCTION Geometry const & @@ -154,6 +159,11 @@ getGeometry(Intersects const &pred) { return pred._geometry; } +template +KOKKOS_INLINE_FUNCTION Geometry getGeometry(Intersects &&pred) +{ + return pred._geometry; +} template KOKKOS_INLINE_FUNCTION Geometry const & @@ -161,6 +171,12 @@ getGeometry(Experimental::OrderedSpatial const &pred) { return pred._geometry; } +template +KOKKOS_INLINE_FUNCTION Geometry +getGeometry(Experimental::OrderedSpatial &&pred) +{ + return pred._geometry; +} template struct PredicateWithAttachment : Predicate