
Hi all, I am using Boost.Proto with Boost 1.42.0 and Visual Studio 2005/2008. I try to handle literal strings in the context of my DSEL: struct CContext { ... template<> struct eval<CExpression<proto::terminal<const char*>::type> > { typedef void result_type; result_type operator()(CExpression<proto::terminal<const char*>::type> Expr, CContext& Ctx) const { return; } }; ... }; But the eval for literal strings is never matched. Instead the general proto::tag::terminal eval is matched which is defined afterwards. I tried several variations like char const[proto::N] and the like, without success. What am I missing here? A full example follows at the end. Regards, Steffen ------------------------------ #include <iostream> #include <boost/proto/proto.hpp> namespace proto = boost::proto; struct CTerminal; struct CGrammar : proto::or_< proto::shift_right<CGrammar, CGrammar>, proto::terminal<proto::_> > { }; struct CDomain; template <typename TExpr> struct CExpression : proto::extends<TExpr, CExpression<TExpr>, CDomain> { typedef proto::extends<TExpr, CExpression<TExpr>, CDomain> base_type; CExpression(const TExpr& Expr = TExpr()) : base_type(Expr) { } }; struct CDomain : proto::domain<proto::generator<CExpression>, CGrammar> { }; struct CTerminal : CExpression<proto::terminal<int>::type> { typedef proto::terminal<int>::type expr_type; CTerminal() : CExpression<expr_type>(expr_type::make(int(0))) { } template <typename TExpr> void operator=(TExpr& Expr) { CContext Ctx; proto::eval(Expr, Ctx); return; } }; // typedef CExpression<proto::terminal<char const[8]>::type> TLiteralString; // typedef CExpression<proto::terminal<char const[proto::N]>::type> TLiteralString; typedef CExpression<proto::terminal<const char*>::type> TLiteralString; struct CContext { template<typename TExpr, typename Tag = typename TExpr::proto_tag> struct eval { }; template<> struct eval<CTerminal> { typedef void result_type; result_type operator()(const CTerminal& Expr, CContext& Ctx) const { std::cout << "CTerminal\n"; return; } }; // why is the literal string not matched by this eval??? template<> struct eval<TLiteralString> { typedef void result_type; result_type operator()(TLiteralString Expr, CContext& Ctx) const { std::cout << "Literal string \"" << proto::value(Expr) << "\"\n"; return; } }; // instead the literal string matches this template<typename TExpr> struct eval<TExpr, proto::tag::terminal> { typedef void result_type; result_type operator()(const TExpr& Expr, CContext& Ctx) const { std::cout << "*** Terminal \"" << proto::value(Expr) << "\"\n"; std::cout << "*** " << typeid(Expr).name() << "\n"; std::cout << "*** " << typeid(TLiteralString).name() << "\n"; return; } }; template<typename TExpr> struct eval<TExpr, proto::tag::shift_right> { typedef void result_type; result_type operator()(const TExpr& Expr, CContext& Ctx) const { std::cout << "ShiftRight\n"; proto::eval(proto::left(Expr), Ctx); proto::eval(proto::right(Expr), Ctx); return; } }; }; int main(int argc, char* argv[]) { CTerminal Foo, Bar; Foo = Bar >> "keyword"; return 0; } -- Sicherer, schneller und einfacher. Die aktuellen Internet-Browser - jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/atbrowser