如何确定eval在proto表达式上返回的类型?

时间:2012-01-22 23:47:13

标签: c++ templates boost metaprogramming boost-proto

我为我的语法定义了一个上下文,它是在输入类型上模板化的,类似于下面的代码片段。我错过了????的类型是

在我开始编写递归模板以解决它们之前,proto中有什么东西吗?

template<typename PlaceholderTypes>  // mpl vector of placeholder types
class calculator_context
    : public proto::callable_context< calculator_context<PlaceholderTypes>, proto::null_context const >
{
public:

    template<typename T>
    struct MakePtrType
    {  
        typedef boost::shared_ptr<T> type;
    };

    // Values to replace the placeholders
    typedef typename boost::mpl::transform<PlaceholderTypes,MakePtrType<boost::mpl::_1> >::type inputTypes;    
    typename boost::fusion::result_of::as_vector<typename inputTypes::type>::type args;

    // Handle the placeholders:
    template<int I>
    typename boost::shared_ptr<boost::mpl::at<PlaceholderTypes,boost::mpl::int_<I> > >::type operator()(proto::tag::terminal, placeholder<I>)         
    {
        typedef typename boost::mpl::at<PlaceholderTypes,boost::mpl::int_<I> >::type param_type;

        boost::shared_ptr<param_type> p = boost::fusion::at_c<I>(this->args);
        return p;        
    }

    // Define the result type of the calculator.
    // (This makes the calculator_context "callable".)        
    typedef ??????? result_type;        

    template <typename Expr1, typename Expr2>
    result_type operator()(proto::tag::plus, const Expr1& lhs, const Expr2& rhs) 
    {        
        typedef ??? lhs_result_type; // result of proto::eval(lhs, ctx);                
        .... 
    }    
};

0 个答案:

没有答案