
On May 21, 6:21 pm, alfC <alfredo.cor...@gmail.com> wrote:
I have a lambda expression that is suppoalways constructed as [some lambda expression] / ( _1 - c); What I need is a function that given the expression returns the internal value of c, if that is possible:
Answering to myself, hope it is useful to someone else: It turns out that extracting c from the lambda expression f_expr is quite easy. just boost::tuples::get<1>(boost::tuples::get<1>(f_expr.args).args), The tricky part is to write the argument type of the function that extracts 'c' only in the case that the expression if of type 'XX/(_1- c)' Below is the full function that has to be defined to extract c, if the expression is not of type XX/(_1-c) the function is not even instantiated: template<class LambdaExp> double extract_c( //typename simple_rational_function<LambdaExp>::type const& // doing a convenient typedef doesn't work, at least for gcc lambda_functor<lambda_functor_base< arithmetic_action<divide_action>, tuple< lambda_functor<// LambdaExp >,// lambda_functor<lambda_functor_base< arithmetic_action<minus_action>, tuple< lambda_functor< placeholder<1> >, double const // <-- attention adds const to avoid unreadable errors > > > > > > f_expr){ return boost::tuples::get<1>(boost::tuples::get<1>(f_expr.args).args); } Suggestions accepted, Alfredo