Skip to content

Commit a1eee19

Browse files
author
Fytch
committed
combine the logic of .single and .multi into a common function
1 parent 5b7eeb2 commit a1eee19

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

ProgramOptions.hxx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,26 +1539,28 @@ namespace po {
15391539
return m_type;
15401540
}
15411541

1542-
option& single() {
1543-
PROGRAMOPTIONS_ASSERT( ( m_multi == false ) || ( m_fallback == nullptr && m_data == nullptr && m_callbacks.empty() ),
1544-
"single() must be set prior to: fallback(), callback(), parsing" );
1542+
option& multi( bool make_multi ) {
1543+
PROGRAMOPTIONS_ASSERT( ( m_multi == make_multi ) || ( m_fallback == nullptr && m_data == nullptr && m_callbacks.empty() ),
1544+
"multi() must be set prior to: fallback(), callback(), parsing" );
15451545
mutable_operation();
1546-
m_multi = false;
1546+
m_multi = make_multi;
15471547
return *this;
15481548
}
1549+
option& single( bool make_single ) {
1550+
return multi( !make_single );
1551+
}
15491552
option& multi() {
1550-
PROGRAMOPTIONS_ASSERT( ( m_multi == true ) || ( m_fallback == nullptr && m_data == nullptr && m_callbacks.empty() ),
1551-
"multi() must be set prior to: fallback(), callback(), parsing" );
1552-
mutable_operation();
1553-
m_multi = true;
1554-
return *this;
1553+
return multi( true );
15551554
}
1556-
bool is_single() const {
1557-
return !is_multi();
1555+
option& single() {
1556+
return single( true );
15581557
}
15591558
bool is_multi() const {
15601559
return m_multi;
15611560
}
1561+
bool is_single() const {
1562+
return !is_multi();
1563+
}
15621564

15631565
private:
15641566
template< typename T >

0 commit comments

Comments
 (0)