diff --git a/src/mesh/ItemArray.hpp b/src/mesh/ItemArray.hpp index 9213bd3132d94da121cd6c78f8bc0d3bba096922..90ba27629874251874801129dd5d250335c393f2 100644 --- a/src/mesh/ItemArray.hpp +++ b/src/mesh/ItemArray.hpp @@ -92,22 +92,13 @@ class ItemArray m_values.fill(data); } - // Following Kokkos logic, these classes are view and const view does allow - // changes in data - PUGS_FORCEINLINE - Array<DataType> - operator[](const ItemId& i) const noexcept(NO_ASSERT) + template <ItemType item_t> + PUGS_INLINE Array<DataType> + operator[](const ItemIdT<item_t>& item_id) const noexcept(NO_ASSERT) { + static_assert(item_t == item_type, "invalid ItemId type"); Assert(this->isBuilt()); - Assert(i < this->numberOfItems()); - return m_values[i]; - } - - template <typename IndexType> - Array<DataType> - operator[](const IndexType&) const noexcept(NO_ASSERT) - { - static_assert(std::is_same_v<IndexType, ItemId>, "ItemArray must be indexed by ItemId"); + return m_values[item_id]; } PUGS_INLINE diff --git a/src/mesh/ItemValue.hpp b/src/mesh/ItemValue.hpp index e6df4b7059a56ee7922c16f50fcf829cff8d8f4d..af45137f55ba9f3d9cefc1391dbe2ba7eb7ec814 100644 --- a/src/mesh/ItemValue.hpp +++ b/src/mesh/ItemValue.hpp @@ -100,21 +100,13 @@ class ItemValue m_values.fill(data); } - // Following Kokkos logic, these classes are view and const view does allow - // changes in data - PUGS_FORCEINLINE - DataType& - operator[](const ItemId& i) const noexcept(NO_ASSERT) + template <ItemType item_t> + PUGS_INLINE DataType& + operator[](const ItemIdT<item_t>& item_id) const noexcept(NO_ASSERT) { + static_assert(item_t == item_type, "invalid ItemId type"); Assert(this->isBuilt()); - return m_values[i]; - } - - template <typename IndexType> - DataType& - operator[](const IndexType&) const noexcept(NO_ASSERT) - { - static_assert(std::is_same_v<IndexType, ItemId>, "ItemValue must be indexed by ItemId"); + return m_values[item_id]; } template <typename DataType2, typename ConnectivityPtr2>