From 7c450f3736e810433a75b787f78fd59c1ccd55e7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 8 Sep 2020 17:52:20 +0300 Subject: [PATCH] Update documentation --- doc/html/lambda2.html | 61 +++++++++++++++++++++++++++++++++++---- doc/lambda2/overview.adoc | 45 +++++++++++++++++++++++++++-- 2 files changed, 99 insertions(+), 7 deletions(-) diff --git a/doc/html/lambda2.html b/doc/html/lambda2.html index 86c27b3..9a50835 100644 --- a/doc/html/lambda2.html +++ b/doc/html/lambda2.html @@ -449,7 +449,12 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
  • Overview @@ -479,13 +484,59 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b

    Description

    -

    …​

    +

    This is a simple, but functional, C++14 lambda library. It takes +advantage of the fact that the standard <functional> header already +provides placeholders _1, _2, _3, and so on, for use with +std::bind, and function objects such as std::plus, std::greater, +std::logical_not, and std::bit_xor, corresponding to arithmetic, +relational, logical and bitwise operators.

    +
    +
    +

    This allows the library to provide a minimal implementation that +still lets expressions such as _1 + 5, _1 % 2 == 0, _1 > _2, +or _1 == ' ' || _1 == '\t' to be composed and used as function +objects.

    +
    +
    +

    These "lambda" expressions can also be freely combined with std::bind. +For example, std::bind( f, _1 ) == std::bind( g, _1 ) and +std::bind( f, _1 + _2 ) both work and have the expected behavior.

    Usage Examples

    -
    -

    …​

    +
    +

    Counting the Even Numbers

    +
    +
    +
    #include <boost/lambda2.hpp>
    +#include <algorithm>
    +
    +using namespace boost::lambda2;
    +
    +int count_even( int const * first, int const * last )
    +{
    +    return std::count_if( first, last, _1 % 2 == 0 );
    +}
    +
    +
    +
    +
    +

    Finding the First Whitespace Character

    +
    +
    +
    #include <boost/lambda2.hpp>
    +#include <algorithm>
    +
    +char const * find_whitespace( char const * first, char const * last )
    +{
    +    using namespace boost::lambda2;
    +
    +    return std::find_if( first, last,
    +        _1 == ' ' || _1 == '\t' || _1 == '\r' || _1 == '\n' );
    +}
    +
    +
    @@ -973,7 +1024,7 @@ the Boost Software License, Versi