lur*_*her 2 c++ s-expression boost-proto c++11
我正在尝试使用boost::proto以下终端构建s表达式对象:
typedef proto::terminal< const char* >::type string_term_t;
typedef proto::terminal< uint32_t >::type uint32_term_t;
typedef proto::terminal< float >::type float_term_t;
Run Code Online (Sandbox Code Playgroud)
并使用它像:
void testInit()
{
auto v = string_term_t("foo") , string_term_t("bla") , (float_term_t(5.6), string_term_t("some"));
proto::display_expr(v);
}
Run Code Online (Sandbox Code Playgroud)
但是这不适合我;
Test.cpp:18:33: error: no matching function for call to ‘boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<const char*>, 0l>::expr(const char [4])’
boost_1_46_0/boost/proto/proto_fwd.hpp:300:16: note: candidates are: boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<const char*>, 0l>::expr()
boost_1_46_0/boost/proto/proto_fwd.hpp:300:16: note: boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<const char*>, 0l>::expr(const boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<const char*>, 0l>&)
Test.cpp:18:33: error: unable to deduce ‘auto’ from ‘<expression error>’
Test.cpp:18:73: error: expected ‘)’ before ‘(’ token
Run Code Online (Sandbox Code Playgroud)
我做错了什么?任何建议如何获得类似或等效于s表达式的东西boost::proto?
该proto::expr<>类型没有定义构造函数; 因此,你的问题.尝试定义这样的类型:
typedef proto::literal< const char* > string_term_t;
typedef proto::literal< uint32_t > uint32_term_t;
typedef proto::literal< float > float_term_t;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
514 次 |
| 最近记录: |