fusion::result_of::transform<Seq1,Seq2,F>

hello,
here's what I'm trying to do:
*.cpp
//result_type() not valid
typedef fusion::vector result_type;
//arg2s_type() is valid
typedef fusion::vector
::type type; //e.g. fusion::vector
};
template<typename Arg1>
struct fun{
fun(const Arg1& args):args_(args_){}
//copy, assign...
// probably not what result_of::transform expects, based on compile
// errors (below)
template
::type type; };
template<typename Arg1>
static typename result<Arg1>::type create(const Arg1& args){
typedef fun<Arg1> f_type;
wrappers_type wrappers;
arg2s_type arg2s;
f_type f(args);
BOOST_MPL_ASSERT(
(
mpl::equal<
Result,
typename result<Arg1>::type
>
)
);//result_of::fun causes compile error
/usr/local/boost_1_35_0/boost/utility/result_of.hpp|34|instantiated from
‘boost::detail::result_of_impl<
factory::fun<Arg1>, factory::fun<Arg1> > ()(boost::mpl::identity<A>,
Arg2A), false>’|
...
//usr/local/boost_1_35_0/boost/utility/result_of.hpp|68|error: wrong
number of template arguments (1, should be 2)|
//factory/range.hpp|32|error: provided for ‘template<class Arg1>
template

AMDG e r wrote:
// probably not what result_of::transform expects, based on compile // errors (below) template
struct result{ typedef typename Metafun::type type; };
Fusion uses Boost.ResultOf. http://www.boost.org/doc/libs/1_36_0/libs/utility/utility.htm#result_of In Christ, Steven Watanabe

Steven Watanabe wrote:
AMDG
e r wrote:
// probably not what result_of::transform expects, based on compile // errors (below) template
struct result{ typedef typename Metafun::type type; }; Fusion uses Boost.ResultOf. http://www.boost.org/doc/libs/1_36_0/libs/utility/utility.htm#result_of
In Christ, Steven Watanabe
Thanks. I read the link above before posting as well as the proposal:
//example from proposal.
struct square_ {
template<typename T> struct result {
typedef T type;
}
template<typename T> T operator()(T& x) const
{
return x*x;
}
};
but I'm not qualified enough to deduce the right answer in my case. i
thought id would be like this:
template<typename Arg1>
struct fun{
template

e r wrote:
Steven Watanabe wrote:
AMDG
e r wrote:
// probably not what result_of::transform expects, based on compile // errors (below) template
struct result{ typedef typename Metafun::type type; }; Fusion uses Boost.ResultOf. http://www.boost.org/doc/libs/1_36_0/libs/utility/utility.htm#result_of
In Christ, Steven Watanabe
Thanks. I read the link above before posting as well as the proposal:
//example from proposal. struct square_ { template<typename T> struct result { typedef T type; }
template<typename T> T operator()(T& x) const { return x*x; } };
but I'm not qualified enough to deduce the right answer in my case. i thought id would be like this:
template<typename Arg1> struct fun{ template
struct result{ typedef typename Metafun::type type; }; template
typename Metafun::type operator()(const Metafun& meta,const Arg2& arg2)const{ typedef typename Metafun::type result_type; return result_type(args,arg2); } }; but apparently it's not correct. I guess I can't fully make sense of F::result
::type. any hint here would be really helpful. thanks!
I may have made a little bit of progress here...
struct fun{
template<typename Signature> struct result;
template<typename A>
struct result

AMDG e r wrote:
I may have made a little bit of progress here...
template<typename A> struct result
{ typedef A type; };
Yeah. That's the idea. I generally use function_traits rather than
partial specialization. In your original example (untested):
#include

Steven Watanabe wrote:
AMDG
e r wrote:
I may have made a little bit of progress here...
template<typename A> struct result
{ typedef A type; }; Yeah. That's the idea. I generally use function_traits rather than partial specialization. In your original example (untested):
#include
#include #include struct fun { template<class Sig> struct result { typedef typename boost::function_traits<Sig>::arg1_type arg1_type; typedef typename boost::function_traits<Sig>::arg2_type arg2_type; typedef typename boost::remove_cv
::type>::type Metafun; typedef typename Metafun::type type; }; // ... } In Christ, Steven Watanabe
Much appreciated, thanks! made changes as suggested and works.
but i can't get this simple algorithm to work (errors shown in the code
below). please help.
algorithm:
map fusion::vector to
fusion::vector

AMDG e r wrote:
typedef typename boost::remove_cv< typename boost::remove_reference
>::type metafun_type;
This should be typename boost::remove_reference
typedef typename metafun_type::type type; };
In Christ, Steven Watanabe

Steven Watanabe wrote:
AMDG
e r wrote:
typedef typename boost::remove_cv< typename boost::remove_reference
>::type metafun_type; This should be typename boost::remove_reference
::type. typedef typename metafun_type::type type; };
In Christ, Steven Watanabe
Oh! I should have spotted that. Thanks for following up throughout!
participants (2)
-
e r
-
Steven Watanabe