百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
B

boolinq

> 编程语言
开源

最简单的 C++ 仅包含头文件的 LINQ 模板库

666 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

最简单的 C++ 仅包含头文件的 LINQ 模板库

boolinq 3.0

Super tiny C++11 single-file header-only LINQ template library

Just imagine .NET Framework LINQ support for STL/Qt collections :)

Get source code here: boolinq.h

Wanna demo?

Example with integers

cpp
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 
// dst items: "Kevin", "Layer", "Agata"

Interesting example

cpp
struct Message {
    std::string PhoneA;
    std::string PhoneB;
    std::string Text;
};

Message messages[] = {
    {"Anton","Troll","Hello, friend!"},
    {"Denis","Wride","OLOLO"},
    {"Anton","Papay","WTF?"},
    {"Denis","Maloy","How r u?"},
    {"Denis","Wride","Param-pareram!"},
};

int DenisUniqueContactCount =
    from(messages).where(   [](const Message & msg) { return msg.PhoneA == "Denis"; })
                  .distinct([](const Message & msg) { return msg.PhoneB; })
                  .count();

// DenisUniqueContactCount == 2    

Test in C++14 using auto

The following test requires C++14 GroupByTestComplex.cpp It uses auto in order to avoid a very long lambda argument type. The return type of a function or lambda expression can be deduced by its operand since C++14. The CMake file is changed so that this test runs with C++14.

…

Containers supported?

  • C++: Native arrays, pairs of pointers
  • STL: list, stack, queue, vector, deque, set, map, any compatible ....
  • Qt: QList, QVector, QSet, QMap.

Operators supported?

Filters and reorders:

  • where(predicate), where_i(predicate)
  • take(count), takeWhile(predicate), takeWhile_i(predicate)
  • skip(count), skipWhile(predicate), skipWhile_i(predicate)
  • orderBy(), orderBy(transform)
  • distinct(), distinct(transform)
  • append(items), prepend(items)
  • concat(linq)
  • reverse()
  • cast()

Transformers:

  • select(transform), select_i(transform)
  • groupBy(transform)
  • selectMany(transfom)

Aggregators:

  • all(), all(predicate)
  • any(), any(lambda)
  • sum(), sum(), sum(lambda)
  • avg(), avg(), avg(lambda)
  • min(), min(lambda)
  • max(), max(lambda)
  • count(), count(value), count(predicate)
  • contains(value)
  • elementAt(index)
  • first(), first(filter), firstOrDefault(), firstOrDefault(filter)
  • last(), last(filter), lastOrDefault(), lastOrDefault(filter)
  • toStdSet(), toStdList(), toStdDeque(), toStdVector()

Bits and Bytes:

  • bytes(ByteDirection?)
  • unbytes(ByteDirection?)
  • bits(BitsDirection?, BytesDirection?)
  • unbits(BitsDirection?, BytesDirection?)

Coming soon:

  • gz()
  • ungz()
  • leftJoin
  • rightJoin
  • crossJoin
  • fullJoin

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C++

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言