-
Notifications
You must be signed in to change notification settings - Fork 11
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
Span with range check #237
Comments
I would further say that most containers we make should to quite 'heavy' debug checking in 'debug' mode, then in production it all gets turned off. I would add to the list quite extensive executor compatibility checking, though a separate issue. So I support this very strongly! |
I think I agree fully, but could you elaborate what you mean by
|
something like this namespace NeoFOAM
{
// in case of debug use DebugSpan instead of span
using span = std::span;
template<typename T>
class DebugSpan : public std::span<T>
{
public:
using std::span<T>::span; // Inherit constructors from std::span
DebugSpan(std::span<T> span) : std::span<T>(span) {}
constexpr T& operator[](std::size_t index) const
{
if (index >= this->size())
{
Kokkos::abort("Index out of range in DebugSpan.\n");
}
return std::span<T>::operator[](index);
}
};
} // namespace NeoFOAM |
I think it would be fine if the check can be disabled for release builds. |
Like this?
|
Span is currently unable to do range checks and this features will be added in 26
https://en.cppreference.com/w/cpp/container/span
I would propose the following:
using NeoFOAM::span = std::span
for debug builds, we would use our on implementation with range checks in the operator[]
What are your toughts do you support the idea?
@greole @gregorweiss @bevanwsjones @MarcelKoch
The text was updated successfully, but these errors were encountered: