Hi,
I have an internally generated templated functor that naturally takes
fusion sequences. since this function can also be called by the user I
want to make it also "unfused"
For example, the struct is
struct F{
typedef result_of::make_map<
p , q ,
double, double
>::type mapped_arguments;
template<class Args> struct result{ typedef double type; };
double operator()(mapped_arguments const& args) const{
return at_key<p>(args) + at_key<q>(args);
}
};
and can be called as
F f;
f(make_map
(one, two));
(I need this because of internal conventions of the library)
but I want it to be also called as
f(one, two); // somehow
(I need this because the user can call it)
I tried this
struct F : unfused{
typedef result_of::make_map<
p , q ,
double, double
>::type mapped_arguments;
template<class Args> struct result{ typedef double type; };
double operator()(mapped_arguments const& args) const{
return at_key<p>(args) + at_key<q>(args);
}
};
but I get:
usr/include/boost/utility/result_of.hpp:80: error: invalid use of
incomplete type ‘const struct F’
I then tried this
struct F_impl{
typedef result_of::make_map<
p , q ,
double, double
>::type mapped_arguments;
template<class Args> struct result{ typedef double type; };
double operator()(mapped_arguments const& args) const{
return at_key<p>(args) + at_key<q>(args);
}
};
struct F : F_impl, unfused{
F() : unfused((F_impl const&)*this){}
F(F_impl const& f) : F_impl(f), unfused((F_impl
const&)*this){}
template<class Args> struct result{ typedef typename
F_impl::result<Args>::type type; };
using F_impl::operator();
};
which seems to work but looks and feels awkward. It works in the sense
that
F f;
can be called
clog << f(make_map(1.,2.)) << endl;
clog << fu(uno, dos) << endl;
Is there any simpler way to get this.
Thank you,
Alfredo