::type
Hi,
I am going through proto user guide. I am getting compiling error for the
following piece code (it's pretty much copy and pasted from the guide). I
used 1.40 and gcc.
#include <iostream>
#include
#include
#include
#include
#include <cmath>
#include <vector>
namespace proto = boost::proto;
template<int I> struct placeholder {};
// Define some placeholders
proto::terminal< placeholder< 1 > >::type const _1 = {{}};
proto::terminal< placeholder< 2 > >::type const _2 = {{}};
struct calculator_context
: proto::callable_context< calculator_context const >
{
// Values to replace the placeholders
std::vector<double> args;
// Define the result type of the calculator.
// (This makes the calculator_context "callable".)
typedef double result_type;
// Handle the placeholders:
template<int I>
double operator()(proto::tag::terminal, placeholder) const
{
return this->args[I];
}
};
// Define a pow_fun function object
template<int Exp>
struct pow_fun
{
typedef double result_type;
double operator()(double d) const
{
return std::pow(d, Exp);
}
};
// Define a lazy pow() function for the calculator DSEL.
// Can be used as: pow< 2 >(_1)
template
typename proto::function<
typename proto::terminal::type
, Arg const &
pow1(Arg const &arg)
{
typedef
typename proto::function<
typename proto::terminal::type
, Arg const &
>::type
result_type;
result_type result = {{{}}, arg};
return result;
}
int main()
{
calculator_context ctx;
ctx.args.push_back(3);
std::cout << boost::proto::eval( pow1<2>( _1 ), ctx );
return 0;
}
The error says:
calc2.cpp: In function 'int main()':
calc2.cpp:116: error: no matching function for call to
'eval(boost::proto::exprns_::expr >, 0l>, const
boost::proto::exprns_::expr >, 0l>&>, 2l>,
calculator_context&)'
/auto/cigprod/spg/lx86_64/opt/boost_1_40_0/boost/proto/eval.hpp:91: note:
candidates are: typename boost::proto::result_of::eval::type
boost::proto::eval(Expr&, Context&) [with Expr =
boost::proto::exprns_::expr >, 0l>, const
boost::proto::exprns_::expr >, 0l>&>, 2l>, Context =
calculator_context]
/auto/cigprod/spg/lx86_64/opt/boost_1_40_0/boost/proto/eval.hpp:100: note:
typename boost::proto::result_of::eval::type
boost::proto::eval(Expr&, const Context&) [with Expr =
boost::proto::exprns_::expr >, 0l>, const
boost::proto::exprns_::expr >, 0l>&>, 2l>, Context =
calculator_context]
Thanks.
--
View this message in context: http://www.nabble.com/boost%3A%3Aproto-user-guide---compile-error-creating-a...
Sent from the Boost - Users mailing list archive at Nabble.com.