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

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext
make_unfused_generic
Description

Creates a unfused_generic adapter for a given, unary Polymorphic Function Object. The usual element conversion is applied to the target function.

Synopsis
template <typename F>
inline typename make_unfused_generic<F>::type
make_unfused_generic(F const & f);
Parameters

Parameter

Requirement

Description

f

Model of Polymorphic Function Object

The function to transform.

Expression Semantics
make_unfused_generic(f);

Return type: A specialization of unfused_generic.

Semantics: Returns a unfused_generic adapter for f.

Header
#include <boost/fusion/functional/generation/make_unfused_generic.hpp>
#include <boost/fusion/include/make_unfused_generic.hpp>
Example
struct bottles_song
{
    typedef void result_type;

    template<class Seq>
    void operator()(Seq & s) const
    {
        typename result_of::at_c<Seq,0>::type n = at_c<0>(s);
        typename result_of::at_c<Seq,1>::type what = at_c<1>(s);

        std::cout
            << n << " bottles of " << what << " on the wall.\n"
            << n << " bottles of " << what << "!\n"
            << "Take one down - pass it around.\n";

        n -= 1; // glug glug...

        std::cout
            << n << " bottles of " << what << " on the wall.\n"
            << std::endl;
    }
};

void try_it()
{
    unsigned n_milk = 99;
    for(int i = 0; i < 3; ++i)
        make_unfused_generic(bottles_song())(n_milk,"milk");
    // 96 bottles left for me
}
See also

PrevUpHomeNext