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) >
{};