c ++ 11,无法编译嵌套模板struct

时间:2018-09-10 03:37:34

标签: c++ c++11

我使用的是开放源代码,但其中的部分代码无法成功编译

template <typename T>
struct Function_Traits
    : public Function_Traits<decltype(&T::operator())>
{};
// For generic types, directly use the result of the signature of its 'operator()'

template <typename ClassType, typename ReturnType, typename... Args>
struct Function_Traits<ReturnType(ClassType::*)(Args...) const>
    // we specialize for pointers to member function
{
    enum { arity = sizeof...(Args) };
    // arity is the number of arguments.

    typedef ReturnType result_type;

    template <size_t i>
    struct arg
    {
        typedef typename std::tuple_element<i, std::tuple<Args...>>::type type;
        // the i-th argument is equivalent to the i-th tuple element of a tuple
        // composed of those arguments.
    };

    typedef std::function<ReturnType(Args...)> FunType;
    typedef std::tuple<Args...> ArgTupleType;
};


template<typename F>
void Visit(F&& f)
{
    using T = typename Function_Traits<F>::arg<0>::type;
}

编译器是gcc 5.4.0,它抱怨:

error: expected ‘;’ before ‘<’ token
     using T = typename Function_Traits<F>::arg<0>::type;

为什么这是错误,以及如何解决此错误?

0 个答案:

没有答案