Allow Section objects to be empty

Preserves expect Deck-like behaviour by allowing empty sections.
This commit is contained in:
Jørgen Kvalsvik
2016-05-02 11:29:10 +02:00
parent 79a8f6efc5
commit 63fd998e2a
2 changed files with 5 additions and 4 deletions

View File

@@ -49,10 +49,11 @@ namespace Opm {
};
auto first = std::find_if( deck.begin(), deck.end(), fn );
if( first == deck.end() )
throw std::invalid_argument( std::string( "Deck requires a '" ) + keyword + "' section" );
auto last = std::find_if( first + 1, deck.end(), &isSectionDelimiter );
if( first == deck.end() )
return { first, first };
auto last = std::find_if( first + 1, deck.end(), isSectionDelimiter );
if( last != deck.end() && last->name() == keyword )
throw std::invalid_argument( std::string( "Deck contains the '" ) + keyword + "' section multiple times" );