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 arg2s_type;
//transforms
// (fusion::vector(),arg2s_type())
// into {A(arg1,Arg2A()),B(arg1,Arg2B()),C(arg1,Arg2C()))}
result_type result(
range::create(
arg1 //arbitrary type Arg1
)
);
here's my attempt. problems/questions are shown in comments.
*.hpp:
template
struct apply_wrapper{
template<typename T>
struct apply{
typedef metafun<T> type;
};
};
template
struct apply_wrapper_to_seq{
typedef typename mpl::transform<
Seq, // e.g. fusion::vector
apply_wrapper<metafun>
::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
struct result{
typedef typename Metafun::type type;
};
template
typename Metafun::type //e.g Metafun = identity<A>
operator()(const Metafun& meta,const Arg2& arg2)const{
typedef typename Metafun::type result_type; //e.g. A
return result_type(args,arg2);
}
const Arg1& args_;
};
template
struct range{
//e.g. fusion
typedef typename apply_wrapper_to_seq<Result>::type wrappers_type;
//e.g. fusion::vector
typedef Arg2s arg2s_type;
template<typename Arg1>
struct result{
typedef typename fusion::result_of::transform<
wrappers_type,
arg2s_type,
fun<Arg1>
::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 struct factory::fun<Arg1>::result’|
//usr/local/boost_1_35_0/boost/fusion/view/transform_view/detail/value_of_impl.hpp|55|error:
no type named ‘type’ in ‘struct
//boost::mpl::apply’|
return fusion::transform(
wrappers,
arg2s,
f
);
}
};
any help would appreciated. thanks!