Skip to content

Commit

Permalink
Added assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Nov 1, 2023
1 parent fa457c7 commit 1a88c74
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/tools/ranges/ViewBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define NJOY_TOOLS_RANGES_VIEWBASE

// system includes
#include <cassert>
#include <stdexcept>

// other includes
Expand Down Expand Up @@ -45,6 +46,7 @@ class ViewBase {
typename Range::iterator > = true >
constexpr decltype(auto) front() const noexcept {

assert( ( !this->empty(), "front(): view is empty" ) );
return *( this->derived().begin() );
}

Expand All @@ -56,6 +58,7 @@ class ViewBase {
typename Range::iterator > = true >
constexpr decltype(auto) back() const noexcept {

assert( ( !this->empty(), "back(): view is empty" ) );
return *( std::prev( this->derived().end() ) );
}

Expand Down

0 comments on commit 1a88c74

Please sign in to comment.