![]() |
Home | Libraries | People | FAQ | More |
Creates a fused
adapter for a given Deferred Callable Object.
The usual element
conversion is applied to the target function.
template <typename F>
inline typename make_fused
<F>::type
make_fused(F const & f);
Parameter | Requirement | Description |
---|---|---|
f |
Model of Deferred Callable Object | The function to transform. |
make_fused(f);
Return type: A specialization of fused
.
Semantics: Returns a fused
adapter for f
.
#include <boost/fusion/functional/generation/make_fused.hpp>
float sub(float a, float b) { return a - b; } void try_it() {vector
<int,float> a(2,2.0f);vector
<int,float> b(1,1.5f);vector
<float,float> c(1.0f,0.5f); assert(c ==transform
(zip
(a,b), make_fused(& sub))); assert(c ==transform
(zip
(a,b), make_fused(std::minus
<float>()))); }
Creates a fused_procedure
adapter for
a given Deferred
Callable Object. The usual element
conversion applied to the target function.
template <typename F>
inline typename make_fused_procedure
<F>::type
make_fused_procedure(F const & f);
Parameter | Requirement | Description |
---|---|---|
f |
Model of Callable Object | The function to transform. |
make_fused_procedure(f);
Return type: A specialization of fused_procedure
.
Semantics: Returns a fused_procedure
adapter for
f
.
#include <boost/fusion/functional/generation/make_fused_procedure.hpp>
vector
<int,int,int> v(1,2,3); using namespace boost::lambda; make_fused_procedure(_1 += _2 - _3)(v); assert(front
(v) == 0);
Creates a fused_function_object
adapter
for a given Deferred
Callable Object. The usual element
conversion is applied to the target function.
template <typename F>
inline typename make_fused_function_object
<F>::type
make_fused_function_object(F const & f);
Parameter | Requirement | Description |
---|---|---|
f |
Model of Polymorphic Function Object | The function to transform. |
make_fused_function_object(f);
Return type: A specialization of fused_function_object
.
Semantics: Returns a fused_function_object
adapter
for f
.
#include <boost/fusion/functional/generation/make_fused_function_object.hpp>
struct sub { template<typename T, typename _> struct result { typedef T 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 ==transform
(zip
(a,b), make_fused_function_object(sub()))); }
Creates a unfused_generic
adapter for
a given, unary Polymorphic
Function Object. The usual element
conversion is applied to the target function.
template <typename F>
inline typename make_unfused_generic
<F>::type
make_unfused_generic(F const & f);
Parameter | Requirement | Description |
---|---|---|
f |
Model of Polymorphic Function Object | The function to transform. |
make_unfused_generic(f);
Return type: A specialization of unfused_generic
.
Semantics: Returns a unfused_generic
adapter for
f
.
#include <boost/fusion/functional/generation/make_unfused_generic.hpp>
struct bottles_song
{
template<class Seq>
struct result
: mpl::if_< mpl::less< result_of::size
<Seq>, mpl::int_<2> >,
boost::blank, mpl::identity<void> >::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
}
Creates a unfused_lvalue_args
adapter
for a given, unary Polymorphic
Function Object. The usual element
conversion is applied to the target function.
template <typename F>
inline typename make_unfused_lvalue_args
<F>::type
make_unfused_lvalue_args(F const & f);
Parameter | Requirement | Description |
---|---|---|
f |
Model of Polymorphic Function Object | The function to transform. |
make_unfused_lvalue_args(f);
Return type: A specialization of unfused_lvalue_args
.
Semantics: Returns a unfused_lvalue_args
adapter
for f
.
#include <boost/fusion/functional/generation/make_unfused_lvalue_args.hpp>
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()
{
int a = 2; char b = 'X';
make_unfused_lvalue_args(fused_incrementer())(a,b);
assert(a == 3 && b == 'Y');
}
Creates a unfused_rvalue_args
adapter
for a given, unary Polymorphic
Function Object. The usual element
conversion is applied to the target function.
template <typename F>
inline typename make_unfused_rvalue_args
<F>::type
make_unfused_rvalue_args(F const & f);
Parameter | Requirement | Description |
---|---|---|
f |
Model of Polymorphic Function Object | The function to transform. |
make_unfused_rvalue_args(f);
Return type: A specialization of unfused_rvalue_args
.
Semantics: Returns a unfused_rvalue_args
adapter
for f
.
#include <boost/fusion/functional/generation/make_unfused_rvalue_args.hpp>
struct sequence_printer { template <class Seq> struct result { typedef void type; }; template <class Seq> void operator()(Seq const & s) const { std::cout << s << std::endl; } }; void try_it() { make_unfused_rvalue_args(sequence_printer()) (24,"bottles of beer in",'a',"box."); }
Copyright © 2001-2005 Joel de Guzman, Dan Marsden |