简体   繁体   English

错误:typedef name可能不是嵌套名称说明符

[英]error: typedef name may not be a nested-name-specifier

I am trying to do something along the lines of this answer , and struggling: 我试图按照这个答案的方式做一些事情,并努力:

$ gcc --version
gcc (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4)

file.cpp:7: error: template argument 1 is invalid  
file.cpp:7: error: typedef name may not be a nested-name-specifier

And the offending part of the file: 以及文件的违规部分:

template <class R, class C, class T0=void, class T1=void, class T2=void>
struct MemberWrap;

template <class R, class C, class T0>
struct MemberWrap<R, C, T0>{
    typedef R (C::*member_t)(T0);
    typedef typename boost::add_reference<typename T0>::type> TC0; // <---- offending line

    MemberWrap(member_t f)
        : m_wrapped(f){
    }

    R operator()(C* p, TC0 p0){
        GILRelease guard;
        return (p->*(this->m_wrapped))(p0);
    }

    member_t m_wrapped;
};

Drop typename from typename T0 in typename T0中删除typename

typedef typename boost::add_reference<typename T0>::type> TC0;

and probably drop the second angle bracket as well. 并且可能也会掉落第二个尖括号。 Ie

typedef typename boost::add_reference<T0>::type TC0;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM