accumulator taking a deduced argument - endless compilation time

Hello, Comments are in the code. Any help appreciated. *.hpp template<typename RealType,typename Id> class mu : public accumulator_base { typedef mu<RealType,Id> self_type; typedef parameter::deduced<self_type> par0_type; typedef parameter::parameters<par0_type> params; public: typedef RealType result_type; mu(result_type value):value_(value){} template<typename Args> mu(const Args& args):value_((result_type)(0)){ // compile bottleneck (caused by the assigment, not the rhs) const self_type& input = params()(args); value_ = input.value_; } private: result_type value_; }; *cpp: typedef mpl::int_<0> id0_t; typedef accumulators::tag::mu<id0_t> mu0_t; typedef boost::mpl::vector< mu0_t > explicit_entities; typedef double value_type; typedef accumulators::accumulator_set< value_type, explicit_entities > acc_type; typedef mpl::apply<mu0_t::impl,value_type>::type input0_type; input0_type input0(0.5); // acc_type acc; // compiles fast acc_type acc((input0)); // compiles forever

er wrote:
Hello,
Comments are in the code. Any help appreciated.
*.hpp
template<typename RealType,typename Id> class mu : public accumulator_base { typedef mu<RealType,Id> self_type; typedef parameter::deduced<self_type> par0_type; typedef parameter::parameters<par0_type> params; public: typedef RealType result_type; mu(result_type value):value_(value){}
template<typename Args> mu(const Args& args):value_((result_type)(0)){ // compile bottleneck (caused by the assigment, not the rhs) const self_type& input = params()(args); value_ = input.value_; } private: result_type value_; };
*cpp:
typedef mpl::int_<0> id0_t; typedef accumulators::tag::mu<id0_t> mu0_t; typedef boost::mpl::vector< mu0_t > explicit_entities;
typedef double value_type; typedef accumulators::accumulator_set< value_type, explicit_entities > acc_type;
typedef mpl::apply<mu0_t::impl,value_type>::type input0_type;
input0_type input0(0.5); // acc_type acc; // compiles fast acc_type acc((input0)); // compiles forever
I've realized I wasn't using deduced properly. Something like this? typedef parameter::parameters< parameter::required< parameter::deduced<tag_type>, is_same<mpl::_1,self_type> > > params; Should allow and ArgPack of the form ((tag = x)) or ((x)), provided x is of type self_type, right?

on Sun Feb 22 2009, er <erwann.rogard-AT-gmail.com> wrote:
I've realized I wasn't using deduced properly. Something like this?
typedef parameter::parameters< parameter::required< parameter::deduced<tag_type>, is_same<mpl::_1,self_type> >
params;
Should allow and ArgPack of the form ((tag = x)) or ((x)), provided x is of type self_type, right?
Yes, that looks right to me. -- Dave Abrahams BoostPro Computing http://www.boostpro.com

David Abrahams wrote:
on Sun Feb 22 2009, er <erwann.rogard-AT-gmail.com> wrote:
I've realized I wasn't using deduced properly. Something like this?
typedef parameter::parameters< parameter::required< parameter::deduced<tag_type>, is_same<mpl::_1,self_type> >
params;
Should allow and ArgPack of the form ((tag = x)) or ((x)), provided x is of type self_type, right?
Yes, that looks right to me.
Thank you for your answer, but I would still need a bit of help: I'm trying to fetch an argument only by its type, not its name or position. For example, I can't replace ((x)) above by say ((x,y)) where only x has the desired type, because apparently, this is not a proper way to form an ArgPack. I've tried to simplify my intent in the code below. *.hpp struct no_name_{}; namespace tag{ ::boost::parameter::keyword<no_name_>& no_name = ::boost::parameter::keyword<no_name_>::get(); }//tag struct A{ typedef parameter::parameters< parameter::required< parameter::deduced<no_name_>, is_same<mpl::_1,A> > > params; explicit A(double x):x_(x){} template<typename Args> A(const Args& args):x_(0){ const A& a = (params()(args))[tag::no_name]; x_ = a.x_; }; double x_; }; *.cpp A a0(0.9); A a1((a0,0.5));// left-hand operand of comma has no effect std::cout << "a1.x_=" << a1.x_ << std::endl; // I want 0.9 here

On Feb 24, 2009, at 11:29 PM, er wrote:
David Abrahams wrote:
on Sun Feb 22 2009, er <erwann.rogard-AT-gmail.com> wrote:
I've realized I wasn't using deduced properly. Something like this?
typedef parameter::parameters< parameter::required< parameter::deduced<tag_type>, is_same<mpl::_1,self_type> >
params;
Should allow and ArgPack of the form ((tag = x)) or ((x)), provided x is of type self_type, right? Yes, that looks right to me.
Thank you for your answer, but I would still need a bit of help:
I'm trying to fetch an argument only by its type, not its name or position.
For example, I can't replace ((x)) above by say ((x,y)) where only x has the desired type, because apparently, this is not a proper way to form an ArgPack.
Sorry, I'm not aware of a way of forming an argument pack with /no/ names other than by using the function call operator on a ParameterSpec. -- David Abrahams BoostPro Computing http://boostpro.com
participants (2)
-
David Abrahams
-
er