From 3c4dfca0d7154a31c569ea893f60380981b8b425 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Sun, 2 Aug 2020 22:11:43 +0200 Subject: [PATCH] Fix warning in assertion --- src/mesh/SubItemValuePerItem.hpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/mesh/SubItemValuePerItem.hpp b/src/mesh/SubItemValuePerItem.hpp index 8189fc13a..66af694c7 100644 --- a/src/mesh/SubItemValuePerItem.hpp +++ b/src/mesh/SubItemValuePerItem.hpp @@ -55,8 +55,7 @@ class SubItemValuePerItem public: template <typename IndexType> - PUGS_INLINE const DataType& - operator[](IndexType i) const noexcept(NO_ASSERT) + PUGS_INLINE const DataType& operator[](IndexType i) const noexcept(NO_ASSERT) { static_assert(std::is_integral_v<IndexType>, "SubView is indexed by integral values"); Assert(i < m_size); @@ -64,8 +63,7 @@ class SubItemValuePerItem } template <typename IndexType> - PUGS_FORCEINLINE DataType& - operator[](IndexType i) noexcept(NO_ASSERT) + PUGS_FORCEINLINE DataType& operator[](IndexType i) noexcept(NO_ASSERT) { static_assert(std::is_integral_v<IndexType>, "SubView is indexed by integral values"); Assert(i < m_size); @@ -104,10 +102,10 @@ class SubItemValuePerItem PUGS_FORCEINLINE DataType& operator()(IndexType item_id, SubIndexType i) const noexcept(NO_ASSERT) { - static_assert(std::is_same_v<IndexType, ItemId>, "first index must be an ItemId"); + static_assert(std::is_same_v<IndexType, ItemId>, "first index must be of the correct ItemId type"); static_assert(std::is_integral_v<SubIndexType>, "second index must be an integral type"); Assert(this->isBuilt()); - Assert(i < m_host_row_map(size_t{item_id} + 1) - m_host_row_map(size_t{item_id})); + Assert(i + m_host_row_map(size_t{item_id}) < m_host_row_map(size_t{item_id} + 1)); return m_values[m_host_row_map(size_t{item_id}) + i]; } @@ -122,8 +120,7 @@ class SubItemValuePerItem // Following Kokkos logic, these classes are view and const view does allow // changes in data template <typename ArrayIndexType> - DataType& - operator[](const ArrayIndexType& i) const noexcept(NO_ASSERT) + DataType& operator[](const ArrayIndexType& i) const noexcept(NO_ASSERT) { static_assert(std::is_integral_v<ArrayIndexType>, "index must be an integral type"); Assert(this->isBuilt()); -- GitLab