#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 );
+}
+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
…
+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.
…
+#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 );
+}
+#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' );
+}
+