Skip to content
Snippets Groups Projects
Commit 72392790 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Simplify slightly implementation

parent 98f40f87
No related branches found
No related tags found
1 merge request!133Simplify access functions to the number of items
...@@ -92,22 +92,13 @@ class ItemArray ...@@ -92,22 +92,13 @@ class ItemArray
m_values.fill(data); m_values.fill(data);
} }
// Following Kokkos logic, these classes are view and const view does allow template <ItemType item_t>
// changes in data PUGS_INLINE Array<DataType>
PUGS_FORCEINLINE operator[](const ItemIdT<item_t>& item_id) const noexcept(NO_ASSERT)
Array<DataType>
operator[](const ItemId& i) const noexcept(NO_ASSERT)
{ {
static_assert(item_t == item_type, "invalid ItemId type");
Assert(this->isBuilt()); Assert(this->isBuilt());
Assert(i < this->numberOfItems()); return m_values[item_id];
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");
} }
PUGS_INLINE PUGS_INLINE
......
...@@ -100,21 +100,13 @@ class ItemValue ...@@ -100,21 +100,13 @@ class ItemValue
m_values.fill(data); m_values.fill(data);
} }
// Following Kokkos logic, these classes are view and const view does allow template <ItemType item_t>
// changes in data PUGS_INLINE DataType&
PUGS_FORCEINLINE operator[](const ItemIdT<item_t>& item_id) const noexcept(NO_ASSERT)
DataType&
operator[](const ItemId& i) const noexcept(NO_ASSERT)
{ {
static_assert(item_t == item_type, "invalid ItemId type");
Assert(this->isBuilt()); Assert(this->isBuilt());
return m_values[i]; return m_values[item_id];
}
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");
} }
template <typename DataType2, typename ConnectivityPtr2> template <typename DataType2, typename ConnectivityPtr2>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment