Skip to content

Commit

Permalink
Update the type expected by View::operator[]
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Bocci <andrea.bocci@cern.ch>
  • Loading branch information
fwyzard authored and bernhardmgruber committed Jul 24, 2023
1 parent 334e265 commit 6abab49
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/alpaka/mem/view/ViewAccessOps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace alpaka::internal
using const_pointer = value_type const*;
using reference = value_type&;
using const_reference = value_type const&;
using Idx = alpaka::Idx<TView>;

public:
ViewAccessOps()
Expand Down Expand Up @@ -63,13 +64,13 @@ namespace alpaka::internal
return data();
}

ALPAKA_FN_HOST auto operator[](std::size_t i) -> reference
ALPAKA_FN_HOST auto operator[](Idx i) -> reference
{
static_assert(Dim<TView>::value == 1, "operator[i] is only valid for Buffers and Views of dimension 1");
return data()[i];
}

ALPAKA_FN_HOST auto operator[](std::size_t i) const -> const_reference
ALPAKA_FN_HOST auto operator[](Idx i) const -> const_reference
{
static_assert(Dim<TView>::value == 1, "operator[i] is only valid for Buffers and Views of dimension 1");
return data()[i];
Expand All @@ -79,7 +80,6 @@ namespace alpaka::internal
template<std::size_t TDim, typename TIdx>
[[nodiscard]] ALPAKA_FN_HOST auto ptr_at([[maybe_unused]] Vec<DimInt<TDim>, TIdx> index) const -> const_pointer
{
using Idx = alpaka::Idx<TView>;
static_assert(
Dim<TView>::value == TDim,
"the index type must have the same dimensionality as the Buffer or View");
Expand Down

0 comments on commit 6abab49

Please sign in to comment.