...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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>
template <class Function> class fused_function_object;
Parameter |
Description |
Default |
---|---|---|
Function |
|
Notation
A possibly const qualified Polymorphic Function Object type or reference type thereof
An object convertible to R
A Sequence of arguments that are accepted by r
An instance of fused<R>
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. |
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())); }