
Joel Falcou wrote:
Let's say I have a grammar which have the following terminal proto::terminal<std::pair<_,_>>
I want to retrieve the first type of the pair in the terminal. Can I write :
when< terminal< pair<_,_> >, _value::first()>
Nope, sorry.
or should I wrote a small meta-function that extract this type ?
when< terminal< pair<_,_> >, first_(_value)>
You'll have to write a callable polymorphic function object. Something like: struct first : proto::callable { template<class Sig> struct result; template<class This, class Pair> struct result<This(Pair)> { typedef typename remove_reference<Pair>::type::first_type type; }; template<class Pair> typename Pair::first_type operator()(Pair const &pair) const { return pair.first; } }; HTH, -- Eric Niebler BoostPro Computing http://www.boostpro.com