A single-header library providing .NET-style LINQ query operations through expression templates with zero-overhead lazy evaluation. The default mode uses only the standard library, requires C++17, and works with STL-compatible containers. Qt support is optional.
const auto grades = std::vector{ 'A', 'C', 'B', 'A', 'B', 'A' };
const auto totals = linq::from(&grades)
.count_by([](char grade) { return grade; })
.order_by([](const auto& entry) { return entry.first; })
.to_vector(); // or to_qvector with Qt
// { {'A', 3}, {'B', 2}, {'C', 1} }- Simpler alternative to C++20
<ranges> - Compile-time type resolution with no virtual dispatch
- Lazy evaluation so query pipelines run only when iterated
- Immutability-focused behavior with minimal side effects
- Efficient pipelines that avoid copies and move data when possible
constexprsupport for operation chains at compile time- First-class support for standard library and Qt containers
Just drop linq.hpp into your source tree and #include from there, or using add_subdirectory in CMake.
linq provides various operators, each explained along with examples. Visit the website.
linq is continuously tested in CI with GCC 12-14, Clang 16-18, the latest AppleClang on GitHub Actions, the current MSVC toolset on GitHub Actions, and Qt 6 on Linux.
Configure with cmake --preset dev for the debug + ASan workflow, or cmake --preset release for the release workflow with clang-tidy where supported.
Build with cmake --build --preset <preset> and run tests with ctest --preset <preset>.
This project is licensed under the MIT license.