Boost logo

Proto :

Subject: Re: [proto] no matching function
From: Eric Niebler (eric_at_[hidden])
Date: 2010-10-09 14:38:26

On 10/7/2010 2:05 AM, Mauro Bianco wrote:
> Hi all,
> When writing a simple proto program to deal with fraction expressions
> (just an exercise to get accustomed with proto library) we run into a
> compiler error that we are not able to fix.
> The error gcc gives is:
> In function ‘int main()’:
> error: no matching function for call to
> ‘eval(boost::proto::exprns_::expr<boost::proto::tag::function,
> boost::proto::argsns_::list2<const
> simexpr<boost::proto::exprns_::expr<boost::proto::tag::terminal,
> boost::proto::argsns_::term<simplifyfct>, 0l> >&, const
> frac_calculator<boost::proto::exprns_::expr<boost::proto::tag::terminal,
> boost::proto::argsns_::term<const frac&>, 0l> >&>, 2l>, frac_context&)’

This is my fault. I was a bit over-eager in pruning overloads to improve
compile times. There is an overload of proto::eval that takes "Expr &"
but no overload that takes "Expr const &". You usually don't notice
because you aren't passing non-const-qualified rvalue expressions to
eval (all of Proto's operator overloads const-qualify the expressions
they return), but in your case, that's exactly what you're doing.

I have corrected the problem on trunk. You can avoid the problem by
making sure you don't pass a non-const rvalue to eval. So for instance,
define a func make_lvalue as:

  template<class T>
  T const & make_lvalue( T const & t ) { return t; }

Then invoke eval as:

  c = proto::eval( make_lvalue( RemoveSim()( TESTEXPR ) ), C);

Sorry for the hoop-jumping.

Eric Niebler
BoostPro Computing

Proto list run by eric at