Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict checking ArrayView validity to debug mode. #16115

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion include/deal.II/base/array_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,12 @@ template <typename ElementType, typename MemorySpaceType>
inline ArrayView<ElementType, MemorySpaceType>::ArrayView(
value_type *starting_element,
const std::size_t n_elements)
: starting_element(n_elements > 0 ? starting_element : nullptr)
:
#ifdef DEBUG
starting_element(n_elements > 0 ? starting_element : nullptr)
#else
starting_element(starting_element)
#endif
, n_elements(n_elements)
{}

Expand All @@ -414,10 +419,14 @@ inline void
ArrayView<ElementType, MemorySpaceType>::reinit(value_type *starting_element,
const std::size_t n_elements)
{
#ifdef DEBUG
if (n_elements > 0)
this->starting_element = starting_element;
else
this->starting_element = nullptr;
#else
this->starting_element = starting_element;
#endif
this->n_elements = n_elements;
}

Expand Down