coveo::linq
Implementation of .NET-like LINQ operators in C++
Functions
LINQ operator chaining

How to chain LINQ operators into an expression. More...

Functions

template<typename Seq , typename Op >
auto coveo::linq::operator| (Seq &&seq, Op &&op) -> decltype(std::forward< Op >(op)(std::forward< Seq >(seq)))
 Applies LINQ operators and allows chaining. More...
 

Detailed Description

In order to create powerful LINQ expressions, operators need to be chained together so as to be applied in a specific order. To do this, coveo::linq::operator|() has been overloaded. Every LINQ operator returns a function object that is applied on the current sequence by coveo::linq::operator|(). By aligning the instances of | in the code, LINQ expressions are easy to read:

using namespace coveo::linq;
auto seq = from(some_sequence)
| linq_op_1(...)
| linq_op_2(...)
| ...;

Function Documentation

◆ operator|()

template<typename Seq , typename Op >
auto coveo::linq::operator| ( Seq &&  seq,
Op &&  op 
) -> decltype(std::forward<Op>(op)(std::forward<Seq>(seq)))

Applies a given LINQ operator to the current sequence. Can be used multiple times to chain many operators in a specific order.

Use like this:

using namespace coveo::linq;
auto result = from(some_sequence)
| linq_op_1(...)
| linq_op_2(...);