I'd try to use IsVector. I'm not sure how to do this with a grammar (maybe someone can pitch in) but you could do something like this
enable_if< IsVector<typename proto::result_of::value<Expr>::type> > On 14 April 2016 at 18:04, Frank Winter <fwin...@jlab.org> wrote: > I made some progress. If I specialize struct VectorSubscriptCtx::eval with > Vector10, like > > > struct VectorSubscriptCtx > { > VectorSubscriptCtx(std::size_t i) : i_(i) {} > > template<typename Expr, typename EnableIf = void> > struct eval > : proto::default_eval<Expr, VectorSubscriptCtx const> > {}; > > template<typename Expr> > struct eval< > Expr > , typename boost::enable_if< > proto::matches<Expr, proto::terminal< Vector10 > > > >::type > > > { > //.. > } > }; > > then it works (is was specialized with Vector). It also works when using > the Boost _ literal (match anything), like > > template<typename Expr> > struct eval< > Expr > , typename boost::enable_if< > proto::matches<Expr, proto::terminal< _ > > > >::type > > > However, I feel this is not good style. Can this be expressed with the > is_base_of trait instead? > > > > > > On 04/14/2016 10:10 AM, Mathias Gaunard wrote: > >> On 14 April 2016 at 14:43, Frank Winter <fwin...@jlab.org >> <mailto:fwin...@jlab.org>> wrote: >> >> Hi all! >> >> Suppose you'd want to implement a simple EDSL (Embedded Domain >> Specific Language) with Boost.proto with the following requirements: >> >> Custom class 'Vector' as terminal >> Classes derived from 'Vector' are working terminals too, e.g. >> Vector10 >> >> [...] >> >> template<typename T> >> struct IsVector >> : mpl::false_ >> {}; >> >> >> template<> >> struct IsVector< Vector > >> : mpl::true_ >> {}; >> >> >> Surely this should be true for all types derived from Vector. >> >> template<typename T, typename Enable = void> >> struct IsVector >> : mpl::false_ >> {}; >> >> template<typename T> >> struct IsVector<T, typanem enable_if< is_base_of<Vector, T> >::type> >> : mpl::true_ >> {}; >> >> >> _______________________________________________ >> proto mailing list >> proto@lists.boost.org >> http://lists.boost.org/mailman/listinfo.cgi/proto >> >> > > _______________________________________________ > proto mailing list > proto@lists.boost.org > http://lists.boost.org/mailman/listinfo.cgi/proto >
_______________________________________________ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto