coveo::linq
Implementation of .NET-like LINQ operators in C++
|
Returns the only element in a sequence. More...
Functions | |
template<typename = void> | |
auto | coveo::linq::single () -> detail::single_impl_0<> |
Returns only element in sequence. More... | |
template<typename Pred > | |
auto | coveo::linq::single (const Pred &pred) -> detail::single_impl_1< Pred > |
Returns only element in sequence satisfying predicate. More... | |
The single
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, an exception is thrown.
This is a terminal operator.
.NET equivalent: Single
auto coveo::linq::single | ( | ) | -> detail::single_impl_0<> |
Returns the only element in a sequence. If the sequence does not have elements or has more than one element, an exception is thrown.
Use like this:
coveo::linq::empty_sequence | The sequence does not have elements. |
coveo::linq::out_of_range | The sequence has more than one element. |
auto coveo::linq::single | ( | const Pred & | pred | ) | -> detail::single_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, an exception is thrown.
Use like this:
pred | Predicate to satisfy. |
pred
returned true
. coveo::linq::empty_sequence | The sequence does not have elements. |
coveo::linq::out_of_range | No element satisfy pred , or more than one element satisfy pred . |