[Fusion] functor fused and unfused at the same time
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 (1.,2.)) << endl;
clog << fu(uno, dos) << endl;
Is there any simpler way to get this.
Thank you,
Alfredo
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.
Sorry, take that back this second option doesn't work either. (So, I don't have a single solution for this). Thank you, Alfredo
participants (1)
-
alfC