Boost-protoチュートリアルを進めており、怠惰なpow関数の例でこの問題に遭遇しました。これはサンプルコードです:
// Define a pow_fun function object
template<int Exp> // , typename Func>
struct pow_fun
{
typedef double result_type;
double operator()(double d) const
{
return pow(d, Exp);
}
};
// Define a lazy pow() function for the calculator DSEL.
// Can be used as: pow< 2 >(_1)
template<int Exp, typename Arg>
typename proto::result_of::make_expr<
proto::tag::function // Tag type
, pow_fun<Exp> // First child (by value)
, Arg const & // Second child (by reference)
>::type const
mypow(Arg const &arg)
{
return proto::make_expr<proto::tag::function>(
pow_fun<Exp>() // First child (by value)
, boost::ref(arg) // Second child (by reference)
);
}
今、私がしようとすると
proto::display_expr( mypow<2>(_1) );
コンパイラは、関数式の演算子<<がないと文句を言います。どうすれば定義できますか?
ありがとう。
コンパイラエラーは次のとおりです。
display_expr :: first_?((const char *) ""):((const char *) "、")))))、boost :: proto :: tag :: proto_tag_name((boost :: proto :: tag :: terminal()、 boost :: proto :: tag :: terminal())))))、((const char *) "("))<< boost :: proto :: value [with Expr = boost :: proto :: exprns_: :expr>、0l>](((const boost :: proto :: exprns _ :: expr>、0l>&)((const boost :: proto :: exprns _ :: expr>、0l> *)expr))) '</ p>