boolinq语言集成查询模板库
boolinq 是用C++实现的语言集成查询模板库,支持STL/Qt 集合类。
用实例说话:
int src[] = {1,2,3,4,5,6,7,8};
auto dst = from(src).where( [](int a){return a%2 == 1;}) // 1,3,5,7
.select([](int a){return a*2;}) // 2,6,10,14
.where( [](int a){return a>2 && a<12;}) // 6,10
.toVector();
// dst type: std::vector// dst items: 6,10
struct Man
{
std::string name;
int age;
};
Man src[] =
{
{"Kevin",14},
{"Anton",18},
{"Agata",17},
{"Terra",20},
{"Layer",15},
};
auto dst = from(src).where( [](const Man & man){return man.age < 18;})
.orderBy([](const Man & man){return man.age;})
.select( [](const Man & man){return man.name;})
.toVector();
// dst type: std::vector// dst items: "Kevin", "Layer", "Agata"评论
