| Home | Libraries | People | FAQ | More

#### unfused

##### Description

An n-ary Polymorphic Function Object adapter template for an unary Polymorphic Function Object target function. When called, its arguments are bundled to a Random Access Sequence of references that is passed to the target function object.

The nullary overload of the call operator can be removed by setting the second template parameter to `false`, which is very useful if the result type computation would result in a compile error, otherwise (nullary call operator's prototypes can't be templates and thus are instantiated as early as the class template).

Only LValue arguments are accepted. To overcome this limitation, apply Boost.Functional/Forward.

The type of the target function is allowed to be const qualified or a reference. Const qualification is preserved and propagated appropriately. In other words, only const versions of `operator()` can be used if the target function object is const - or, in case the target function object is held by value, the adapter is const.

##### Header

    #include <boost/fusion/functional/adapter/unfused.hpp>

##### Synopsis

    template <class Function, bool AllowNullary = true>
    class unfused;

##### Template parameters

Parameter | Description | Default
--- | --- | ---
`Function` | A unary Polymorphic Function Object |
`AllowNullary` | Boolean constant | true

##### Model of

- Polymorphic Function Object
- Deferred Callable Object

Notation

`F`

  A possibly const qualified, unary Polymorphic Function Object type or reference type thereof

`f`

  An object convertible to `F`

`UL`

  The type `unfused<F>`

`ul`

  An instance of `UL`, initialized with `f`

`a0`...`aN`

  Arguments to `ul`

##### Expression Semantics

Expression | Semantics
--- | ---
`UL(f)` | Creates a fused function as described above, initializes the target function with `f`.
`UL()` | Creates a fused function as described above, attempts to use `F`'s default constructor.
`ul(a0`...`aN)` | Calls `f` with a Sequence that contains references to the arguments `a0`...`aN`.

##### Example

    struct fused_incrementer
    {
        template <class Seq>
        struct result
        {
            typedef void type;
        };

        template <class Seq>
        void operator()(Seq const & s) const
        {
            for_each(s,++boost::lambda::_1);
        }
    };

    void try_it()
    {
        unfused<fused_incrementer> increment;
        int a = 2; char b = 'X';
        increment(a,b);
        assert(a == 3 && b == 'Y');
    }

##### See also

- `unfused_typed`
- `make_unfused`