A C++11+ library for lazy evaluation of iterables, minimizing memory usage by using sentinels and reducing redundant data.
cpp-lazy is a C++ library that provides lazy evaluation for iterables, allowing operations like mapping and filtering to be deferred until iteration. It solves the problem of redundant computation and memory usage in C++ by optimizing iterator pairs and using sentinels where possible.
C++ developers working with C++11 or later who need efficient, functional-style lazy evaluation for data processing, especially in performance-sensitive applications where memory and computation overhead matter.
Developers choose cpp-lazy for its memory-efficient design using sentinels, seamless STL integration, and support for modern C++ standards without heavy dependencies, offering a lightweight alternative to manual iteration or other libraries.
C++11 (and onwards) library for lazy evaluation
Uses sentinel optimization to avoid storing redundant end iterators, reducing memory footprint as described in the philosophy section where forward iterators return default_sentinel_t.
Seamlessly integrates with standard library containers and algorithms when not sentinelled, allowing easy adoption in existing C++ code without major refactoring.
Supports the | operator for chaining operations like map and filter, enabling readable and composable data transformations, as shown in basic usage examples.
Compatible with any compiler supporting C++11 or later, ensuring broad usability across different development environments and legacy projects.
Sentinel iterators are not directly compatible with all STL algorithms, requiring explicit use of lz::common for conversion, which adds complexity and potential performance overhead.
Automatic reference holding with lz::maybe_owned can lead to dangling references for non-lz iterables, forcing developers to manually use lz::copied to avoid bugs.
For C++11 to C++14, iterating over sentinel iterators in range-based for loops requires workarounds like lz::for_each, reducing convenience and increasing code verbosity.
stb single-file public domain libraries for C/C++
A modern formatting library
Extremely fast non-cryptographic hash algorithm
List of single-file C/C++ libraries, with emphasis on clause-less licenses.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.