我可以知道转换中与 boost::proto::_ 匹配的类型吗?
在 boost::proto 手册中,有一个与 std::transform<...> 类型的终端匹配的语法示例:
struct StdComplex
: proto::terminal< std::complex< proto::_ > >
{};
我想编写一个对 proto::_ 类型执行某些操作的转换。 例如,当匹配 proto::terminal< 时std::复杂< T> >,它返回一个 boost::shared_ptr < T> 。
这可能吗?
陈述我的问题的另一种方式是,如何使以下代码片段起作用?
template<typename T>
struct Show : proto::callable
{
typedef T result_type;
result_type operator()(T& v)
{
std::cout << "value = " << v << std::endl;
return v;
}
};
struct my_grammar
: proto::when<proto::terminal<proto::_ >, Show<??? what comes here ???>(proto::_value) >
{};
In the boost::proto manual, there is an example of a grammar that matches terminals of type std::transform<...>:
struct StdComplex
: proto::terminal< std::complex< proto::_ > >
{};
I would like to write a transform that does something with the type of the proto::_.
For example, when matching a proto::terminal< std::complex< T > >, it returns a boost::shared_ptr < T > .
Is this possible?
Another way to state my question is, how do I make the following snippet work?
template<typename T>
struct Show : proto::callable
{
typedef T result_type;
result_type operator()(T& v)
{
std::cout << "value = " << v << std::endl;
return v;
}
};
struct my_grammar
: proto::when<proto::terminal<proto::_ >, Show<??? what comes here ???>(proto::_value) >
{};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的显示转换将更容易作为多态函数对象处理:
您对另一个问题的回答是:
Your Show transform will be easier to handle as a Polymorphic Function Object :
Your answer on the other problem is :