cpplinqの紹介

cpplinq - LINQ-like list manipulations for C++11

C++ .NetLINQ っぽく書けるライブラリ。

#include "cpplinq.hpp"

int computes_a_sum ()
{
    using namespace cpplinq;    
    int ints[] = {3,1,4,1,5,9,2,6,5,4};

    // Computes the sum of all even numbers in the sequence above
    return 
            from_array (ints)
        >>  where ([](int i) {return i%2 ==0;})     // Keep only even numbers
        >>  sum ()                                  // Sum remaining numbers
        ;
}

似たようなライブラリはたくさんありますね。 今は boost::range v2 が王道でしょうか。

Range 周り、標準で早く決まればいいのですが。range v3 の開発→標準化がスムーズにいけばいいなぁ。