Здравствуйте.
Такой код
#include <iostream>
#include <vector>
using namespace std;
template<typename T> class vct:public vector<T>{
public:
using vector<T>::begin;
using vector<T>::end;
using typename vector<T>::iterator;
vct():vector<T>(1){}
void print(){
iterator b=begin(),e=end();
cout<<(e-b);
}
};
int main(){
vct<int> a;
a.print();
}
Comeau online, Builder 6 компилят(ну нет у меня MSVC)
GCC не компилит
имеем ошибку в print(iterator — неизвестный тип):
In member function `void vct<T>::print()':
12: error: expected `;' before "b"
13: error: `e' was not declared in this scope
13: error: `b' was not declared in this scope
In member function `void vct<T>::print() [with T = int]':
19: instantiated from here
12: error: expected primary-expression
проверял на g++ 3.4.5 (mingw special) и g++ 4.0.3 под linux
Кто не прав(я/gcc/comeau)?
Может есть идеи как красиво обойти глюк gcc(если это он)?
(кроме как typedef typename vector<T>::iterator iterator)