类型名C ++错误

| 很抱歉,这个标题含糊不清,很难描述。 我遇到的错误是这个,我不知道这意味着什么:   carray.h:176:错误:'类型名Carray :: is_iterator'名称'template template 结构Carray :: is_iterator',这不是一种类型 我有这个代码片段来检测某个东西是否是一个迭代器,并使用正确的重载(http://stackoverflow.com/questions/6050441/why-does-this-constructor-overload-resolve-incorrect)。这样编译:
template<class T> class Carray {
private:
    // uses SFINAE to determine if the passed in type is indeed an iterator
    template<class It>
    class is_iterator_impl {
    private:
        typedef char yes[1];
        typedef char no[2];

        template<class C>
        static yes& _test(typename C::iterator_category*);

        template<class>
        static no& _test(...);
    public:
        static const bool value = sizeof(_test<It>(0)) == sizeof(yes);
    };

    template<class It, bool check = is_iterator_impl<It>::value> struct is_iterator { typedef void type; };
    template<class It> struct is_iterator<It*, false> { typedef void type; };
    template<class It> struct is_iterator<It, false> { };

public:
    template<class It>
    Carray(It first, It last, typename is_iterator<It>::type *dummy = 0) {
        // create array from 2 iterators
    }
};
现在,我想将实现与声明分开,然后尝试了此操作,但出现了错误:
template<class T> class Carray {
private:
    // uses SFINAE to determine if the passed in type is indeed an iterator
    template<class It> class is_iterator_impl;
    template<class It, bool check = is_iterator_impl<It>::value> struct is_iterator { typedef void type; };
    template<class It> struct is_iterator<It*, false> { typedef void type; };
    template<class It> struct is_iterator<It, false> { };
public:
    template<class It> Carray(It first, It last, typename is_iterator<It>::type *dummy = 0);
};

template<class T>
template<class It>
Carray<T>::Carray(It first, It last, typename Carray<T>::is_iterator<It>::type *dummy) {
    // create array from 2 iterators - ERROR IN THIS DEFINITION
}

template<class T>
template<class It>
class Carray<T>::is_iterator_impl {
private:
    typedef char yes[1];
    typedef char no[2];

    template<class C>
    static yes& _test(typename C::iterator_category*);

    template<class>
    static no& _test(...);
public:
    static const bool value = sizeof(_test<It>(0)) == sizeof(yes);
};
我正在使用g ++ 4.5.5。     
已邀请:
        由于这些类型的问题有些晦涩难懂(即,有很多代码,而且在第一遍中阅读并不容易),因此您应该提供一个可行的(或者是失败的示例)。 我的猜测是您缺少
template
关键字(
Carray
构造函数参数):
typename Carray<T, Allocator>::template is_iterator<InputIterator>::type
//                             ^^^^^^^^
    
        在每一行的末尾检查分号,看起来您已经写了以下内容:
template<class T, class Allocator> 
template<class I, bool check> struct Carray<T, Allocator>::is_iterator
第一行末没有分号,只是一个猜测。     

要回复问题请先登录注册