Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

Lazy Statements

Lazy statements? Sure. There are lazy versions of the C++ statements we all know and love. For example:

if_(arg1 > 5)
[
    std::cout << arg1
]

Say, for example, we wish to print all the elements that are greater than 5 (separated by a comma) in a vector. Here's how we write it:

std::for_each(v.begin(), v.end(),
    if_(arg1 > 5)
    [
        std::cout << arg1 << ", "
    ]
);

(See if.cpp)

Learn more about statements here.


PrevUpHomeNext