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

Casts sequence elements to another type. More...

Functions

template<typename U >
auto coveo::linq::cast () -> detail::select_impl< detail::indexless_selector_proxy< detail::cast_selector< U >>>
 Casts sequence elements to another type. More...
 

Detailed Description

The cast operator modifies a sequence by casting all its element to another type.

.NET equivalent: Cast

Function Documentation

◆ cast()

template<typename U >
auto coveo::linq::cast ( ) -> detail::select_impl<detail::indexless_selector_proxy<detail::cast_selector<U>>>

Casts each element in a sequence to another type and returns a new sequence of all such modified elements. The elements are cast using static_cast.

Use like this:

const int NUMS[] = { 42, 23, 66 };
using namespace coveo::linq;
auto dbls = from(NUMS)
| cast<double>();
// dbls == { 42.0, 23.0, 66.0 }
Template Parameters
UNew type to cast elements to.
Returns
(Once applied) Sequence of cast elements.