https://github.com/cemdervis/linq
linq is a minimalistic, header-only LINQ library for C++ 17 and newer.
https://github.com/cemdervis/linq
cpp cpp17 cpp20 linq modern-cpp sql
Last synced: about 1 year ago
JSON representation
linq is a minimalistic, header-only LINQ library for C++ 17 and newer.
- Host: GitHub
- URL: https://github.com/cemdervis/linq
- Owner: cemdervis
- License: bsl-1.0
- Created: 2025-02-25T18:59:48.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-25T19:13:09.000Z (over 1 year ago)
- Last Synced: 2025-02-25T20:23:32.676Z (over 1 year ago)
- Topics: cpp, cpp17, cpp20, linq, modern-cpp, sql
- Language: C++
- Homepage: https://dervis.de/linq
- Size: 113 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# linq - LINQ for C++

linq is a header-only LINQ library for C++ 17 and newer.
It has no dependencies and neatly integrates into the STL by taking advantage of modern C++ features.
- offers a simpler alternative to C++20 ``
- resolves all type related functionality at compile-time; no virtual dispatch is used
- uses lazy evaluation, so your queries still work even after you modify the container they're based on
- focuses on immutability, so your queries stay predictable by minimizing surprising side-effects
- is efficient in the way it works with your data; it avoids copies and instead moves data wherever it can
- generates an operation chain at compile-time (supports `constexpr`)
- works with all generic container types, not just the STL
---
[](https://github.com/cemdervis/linq/actions/workflows/build-linux-clang.yml) [](https://github.com/cemdervis/linq/actions/workflows/build-linux-gcc.yml) [](https://github.com/cemdervis/linq/actions/workflows/build-macos-appleclang.yml) [](https://github.com/cemdervis/linq/actions/workflows/build-windows-msvc.yml)
## Documentation
The documentation is available on the [home page](https://dervis.de/linq).
## Example
```cpp linenums="1"
#include
#include
#include
#include
struct Person {
std::string name;
int age;
};
int main() {
auto people = std::vector {
{ "Person 1", 20 },
{ "Person 2", 21 },
{ "Person 3", 22 }
};
auto query = linq::from( &people )
.where( []( const Person& p ) { return p.age > 20; } )
.select( []( const Person& p ) { return p.name; } );
for ( const auto& name : query )
std::println( "{}", name );
return 0;
}
```
Output:
```
Person 2
Person 3
```