mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
CSequence: frontOrDefault and backOrDefault taking the default value as an argument
This commit is contained in:
@@ -153,6 +153,11 @@ namespace BlackMisc
|
||||
*/
|
||||
const_reference frontOrDefault() const { static const value_type def; return empty() ? def : front(); }
|
||||
|
||||
/*!
|
||||
* \brief Access the first element, or a default-initialized value if the sequence is empty.
|
||||
*/
|
||||
value_type frontOrDefault(value_type def) const { return empty() ? def : front(); }
|
||||
|
||||
/*!
|
||||
* \brief Access the last element.
|
||||
* \pre The sequence must not be empty.
|
||||
@@ -166,10 +171,15 @@ namespace BlackMisc
|
||||
const_reference back() const { Q_ASSERT(!empty()); return pimpl()->back(); }
|
||||
|
||||
/*!
|
||||
* \brief Access the last element, or a default-initialized value if the sequence is empty.
|
||||
*/
|
||||
* \brief Access the last element, or a default value if the sequence is empty.
|
||||
*/
|
||||
const_reference backOrDefault() const { static const value_type def; return empty() ? def : back(); }
|
||||
|
||||
/*!
|
||||
* \brief Access the last element, or a default value if the sequence is empty.
|
||||
*/
|
||||
value_type backOrDefault(value_type def) const { return empty() ? def : back(); }
|
||||
|
||||
/*!
|
||||
* \brief Returns number of elements in the sequence.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user