coveo::linq
Implementation of .NET-like LINQ operators in C++
|
Returns the only element in a sequence, or a default value. More...
Functions | |
template<typename = void> | |
auto | coveo::linq::single_or_default () -> detail::single_or_default_impl_0<> |
Returns only element in sequence, or default value. More... | |
template<typename Pred > | |
auto | coveo::linq::single_or_default (const Pred &pred) -> detail::single_or_default_impl_1< Pred > |
Returns only element in sequence satisfying predicate, or default value. More... | |
The single_or_default
operator returns the only element in a sequence, or the only element to satisfy a predicate. If the sequence does not have such an element or has more than one of them, a default value is returned instead.
This is a terminal operator.
.NET equivalent: SingleOrDefault
auto coveo::linq::single_or_default | ( | ) | -> detail::single_or_default_impl_0<> |
Returns the only element in a sequence. If the sequence does not have elements or has more than one element, a default-initialized value is returned instead.
Use like this:
auto coveo::linq::single_or_default | ( | const Pred & | pred | ) | -> detail::single_or_default_impl_1<Pred> |
Returns the only element in a sequence that satisfy the given predicate. If no element in the sequence or if more than one element in the sequence satisfy the predicate, a default-initialized value is returned instead.
Use like this:
pred | Predicate to satisfy. |
pred
returned true
, or a default value if either no element satisfy pred
or more than one element satisfy pred
.