placeholders

Description

The placeholders provide std::bind compatible placeholders that additionally provide basic C++ operators that creates bind expressions. Each bind expression supports constexpr function evaluation.

Synopsis

namespace placeholders {
    placeholder<1> _1 = {};
    placeholder<2> _2 = {};
    placeholder<3> _3 = {};
    placeholder<4> _4 = {};
    placeholder<5> _5 = {};
    placeholder<6> _6 = {};
    placeholder<7> _7 = {};
    placeholder<8> _8 = {};
    placeholder<9> _9 = {};
}

Operators

  • Binary operators: +,-,*,/,%,>>,<<,>,<,<=,>=,==,!=,&,^,|,&&,||

  • Assign operators: +=,-=,*=,/=,%=,>>=,<<=,&=,|=,^=

  • Unary operators: !,~,+,-,*,++,–

Example

#include <boost/hof.hpp>
#include <cassert>
using namespace boost::hof;

int main() {
    auto sum = _1 + _2;
    assert(3 == sum(1, 2));
}

unamed placeholder

Header

#include <boost/hof/placeholders.hpp>

Description

The unamed placeholder can be used to build simple functions from C++ operators.

Note: The function produced by the unamed placeholder is not a bind expression.

Synopsis

namespace placeholders {
    /* unspecified */ _ = {};
}

Example

#include <boost/hof.hpp>
#include <cassert>
using namespace boost::hof;

int main() {
    auto sum = _ + _;
    assert(3 == sum(1, 2));
}