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

Add bound checking assertions

Also add access to the connectivity pointer
parent a6b1b6d6
Branches
Tags
1 merge request!84Add SubArray class
...@@ -109,6 +109,17 @@ class SubItemValuePerItem ...@@ -109,6 +109,17 @@ class SubItemValuePerItem
return m_connectivity_ptr.use_count() != 0; return m_connectivity_ptr.use_count() != 0;
} }
PUGS_INLINE
std::shared_ptr<const IConnectivity>
connectivity_ptr() const noexcept
{
if constexpr (std::is_same_v<ConnectivityPtr, ConnectivitySharedPtr>) {
return m_connectivity_ptr;
} else {
return m_connectivity_ptr.lock();
}
}
template <typename IndexType, typename SubIndexType> template <typename IndexType, typename SubIndexType>
PUGS_FORCEINLINE DataType& PUGS_FORCEINLINE DataType&
operator()(IndexType item_id, SubIndexType i) const noexcept(NO_ASSERT) operator()(IndexType item_id, SubIndexType i) const noexcept(NO_ASSERT)
...@@ -128,7 +139,7 @@ class SubItemValuePerItem ...@@ -128,7 +139,7 @@ class SubItemValuePerItem
{ {
static_assert(std::is_integral_v<ArrayIndexType>, "index must be an integral type"); static_assert(std::is_integral_v<ArrayIndexType>, "index must be an integral type");
Assert(this->isBuilt()); Assert(this->isBuilt());
Assert(i < m_values.size()); Assert(static_cast<size_t>(i) < m_values.size());
return m_values[i]; return m_values[i];
} }
...@@ -223,7 +234,6 @@ class SubItemValuePerItem ...@@ -223,7 +234,6 @@ class SubItemValuePerItem
{ {
static_assert(not std::is_const_v<DataType>, "Cannot allocate SubItemValuePerItem of const data: only " static_assert(not std::is_const_v<DataType>, "Cannot allocate SubItemValuePerItem of const data: only "
"view is supported"); "view is supported");
;
ConnectivityMatrix connectivity_matrix = connectivity._getMatrix(item_type, sub_item_type); ConnectivityMatrix connectivity_matrix = connectivity._getMatrix(item_type, sub_item_type);
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment