Skip to content

Commit

Permalink
Fix getGeometry for prvalues
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aprokop committed Oct 11, 2024
1 parent 4243afc commit 43a55fd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/spatial/detail/ArborX_Predicates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,36 @@ getGeometry(Nearest<Geometry> const &pred)
{
return pred._geometry;
}
template <typename Geometry>
KOKKOS_INLINE_FUNCTION Geometry getGeometry(Nearest<Geometry> &&pred)
{
return pred._geometry;
}

template <typename Geometry>
KOKKOS_INLINE_FUNCTION Geometry const &
getGeometry(Intersects<Geometry> const &pred)
{
return pred._geometry;
}
template <typename Geometry>
KOKKOS_INLINE_FUNCTION Geometry getGeometry(Intersects<Geometry> &&pred)
{
return pred._geometry;
}

template <typename Geometry>
KOKKOS_INLINE_FUNCTION Geometry const &
getGeometry(Experimental::OrderedSpatial<Geometry> const &pred)
{
return pred._geometry;
}
template <typename Geometry>
KOKKOS_INLINE_FUNCTION Geometry
getGeometry(Experimental::OrderedSpatial<Geometry> &&pred)
{
return pred._geometry;
}

template <typename Predicate, typename Data>
struct PredicateWithAttachment : Predicate
Expand Down

0 comments on commit 43a55fd

Please sign in to comment.