我有以下代码:
template<typename T, typename Allocator = std::allocator<T> >
class Carray {
// ...
typedef T* pointer;
typedef pointer iterator;
// ...
};
Run Code Online (Sandbox Code Playgroud)
现在我正在尝试进行部分专业化iterator_traits.对我来说似乎没问题,但g ++ 4.4.5抱怨:
#include <iterator>
namespace std {
template<typename T, typename Allocator>
struct iterator_traits<typename Carray<T, Allocator>::iterator> { // line 128
typedef T value_type;
typedef typename Allocator::difference_type difference_type;
typedef typename Allocator::reference reference;
typedef typename Allocator::pointer pointer;
typedef typename std::random_access_iterator_tag iterator_category;
};
}
Run Code Online (Sandbox Code Playgroud)
这是完整的错误消息:
carray.h:128: error: template parameters not used in partial specialization:
carray.h:128: error: ‘T’
carray.h:130: error: …Run Code Online (Sandbox Code Playgroud)