Skip to content

Commit

Permalink
add host device to range fun
Browse files Browse the repository at this point in the history
  • Loading branch information
alfC committed Jul 14, 2024
1 parent 9cddfaf commit a05f992
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/boost/multi/array_ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ struct const_subarray : array_types<T, D, ElementPtr, Layout> {

using index_range = typename const_subarray::index_range;

constexpr auto range(index_range irng) const& -> decltype(auto) {return sliced(irng.front(), irng.front() + irng.size());}
BOOST_MULTI_HD constexpr auto range(index_range irng) const& -> decltype(auto) {return sliced(irng.front(), irng.front() + irng.size());}
// constexpr auto range(index_range irng) && -> decltype(auto) {return std::move(*this).sliced(irng.front(), irng.front() + irng.size());}
// constexpr auto range(index_range irng) & -> decltype(auto) {return sliced(irng.front(), irng.front() + irng.size());}

Expand Down Expand Up @@ -1343,11 +1343,11 @@ struct const_subarray : array_types<T, D, ElementPtr, Layout> {
BOOST_MULTI_HD constexpr auto operator()() const& -> const_subarray {return paren_aux_();} // NOLINT(readability-redundant-access-specifiers,readability-const-return-type)

public:
template<class... As> constexpr auto paren_aux_(index_range rng, As... args) const& {return range(rng).rotated().paren_aux_(args...).unrotated();}
template<class... As> BOOST_MULTI_HD constexpr auto paren_aux_(index_range rng, As... args) const& {return range(rng).rotated().paren_aux_(args...).unrotated();}

// template<class... As> constexpr auto paren_aux_(intersecting_range<index> inr, As... args) & -> decltype(auto) {return paren_aux_(intersection(this->extension(), inr), args...);}
// template<class... As> constexpr auto paren_aux_(intersecting_range<index> inr, As... args) && -> decltype(auto) {return paren_aux_(intersection(this->extension(), inr), args...);}
template<class... As> constexpr auto paren_aux_(intersecting_range<index> inr, As... args) const& -> decltype(auto) {return paren_aux_(intersection(this->extension(), inr), args...);}
template<class... As> BOOST_MULTI_HD constexpr auto paren_aux_(intersecting_range<index> inr, As... args) const& -> decltype(auto) {return paren_aux_(intersection(this->extension(), inr), args...);}

// template<class... As> BOOST_MULTI_HD constexpr auto paren_aux_(index idx, As... args) & -> decltype(auto) {return operator[](idx).paren_aux_(args...);}
// template<class... As> BOOST_MULTI_HD constexpr auto paren_aux_(index idx, As... args) && -> decltype(auto) {return operator[](idx).paren_aux_(args...);}
Expand Down Expand Up @@ -1882,8 +1882,8 @@ class subarray : public const_subarray<T, D, ElementPtr, Layout> {
BOOST_MULTI_HD constexpr auto sliced(index first, index last) & -> subarray { return const_subarray<T, D, ElementPtr, Layout>::sliced(first, last) ; }

using const_subarray<T, D, ElementPtr, Layout>::range;
constexpr auto range(index_range irng) && -> decltype(auto) {return std::move(*this).sliced(irng.front(), irng.front() + irng.size());}
constexpr auto range(index_range irng) & -> decltype(auto) {return sliced(irng.front(), irng.front() + irng.size());}
BOOST_MULTI_HD constexpr auto range(index_range irng) && -> decltype(auto) {return std::move(*this).sliced(irng.front(), irng.front() + irng.size());}
BOOST_MULTI_HD constexpr auto range(index_range irng) & -> decltype(auto) {return sliced(irng.front(), irng.front() + irng.size());}

public:
using const_subarray<T, D, ElementPtr, Layout>::paren_aux_;
Expand Down
2 changes: 2 additions & 0 deletions test/reextent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ BOOST_AUTO_TEST_CASE(array_move_clear) {
BOOST_REQUIRE( arr[4][3] == 660 );
}



BOOST_AUTO_TEST_CASE(array_reextent_1d) {
multi::array<int, 1> arr(multi::extensions_t<1>{ multi::iextension{ 10 } }, 40);
BOOST_REQUIRE( size(arr) == 10 );
Expand Down

0 comments on commit a05f992

Please sign in to comment.