Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Lazy arguments in C++
C C++
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
README.md
lazy.h
lazy_test.cpp

README.md

Lazyargs

This class allows one to use lazy arguments (call-by-need) in C++11. Lazy arguments are evaluated at most once, on first use, using lambdas to store their evaluating function.

Functions taking lazy arguments need to use the lazy wrapping class and the () operator, so

void f(int x) {
...
    g(x);
...
}

becomes

void f(lazy<int> x) {
...
    g( x() );
...
}

Then, anyone who calls a lazy function has to either pass a lambda into make_lazy:

f(make_lazy([&] { return expensive_make_x(); }));

or use the LAZY helper macro (equivalent to the above):

f(LAZY(expensive_make_x()));
Something went wrong with that request. Please try again.