| Home | Libraries | People | FAQ | More

#### fused_function_object

##### Description

An unary Polymorphic Function Object adapter template for a Polymorphic Function Object target function. It takes a Forward Sequence that contains the arguments for the target function.

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 for an target function object that is const or, if the target function object is held by value, the adapter is const).

/functional/adapter/fused_function_object.hpp>

##### Synopsis

    template <class Function>
    class fused_function_object;

##### Template parameters

Parameter | Description | Default
--- | --- | ---
`Function` | Polymorphic Function Object type |

##### Model of

- Polymorphic Function Object
- Deferred Callable Object

Notation

`R`

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

`r`

  An object convertible to `R`

`s`

  A Sequence of arguments that are accepted by `r`

`f`

  An instance of `fused<R>`

##### Expression Semantics

Expression | Semantics
--- | ---
`fused_function_object<R>(r)` | Creates a fused function as described above, initializes the target function with `r`.
`fused_function_object<R>()` | Creates a fused function as described above, attempts to use `R`'s default constructor.
`f(s)` | Calls `r` with the elements in `s` as its arguments.

##### Example

    template<class SeqOfSeqs, class Func>
    typename result_of::transform< zip_view<SeqOfSeqs> const,
        fused_function_object<Func const &> >::type
    n_ary_transform(SeqOfSeqs const & s, Func const & f)
    {
        return transform(zip_view<SeqOfSeqs>(s),
            fused_function_object<Func const &>(f));
    }

    struct sub
    {
        template <typename Sig>
        struct result;

        template <class Self, typename T>
        struct result< Self(T,T) >
        { typedef typename remove_reference<T>::type type; };

        template<typename T>
        T operator()(T lhs, T rhs) const
        {
            return lhs - rhs;
        }
    };

    void try_it()
    {
        vector<int,float> a(2,2.0f);
        vector<int,float> b(1,1.5f);
        vector<int,float> c(1,0.5f);
        assert(c == n_ary_transform(vector_tie(a,b), sub()));
    }

##### See also

- `fused`
- `fused_procedure`
- `invoke_function_object`
- `deduce`