dependent-name ‘xxx::yyy’ is parsed as a non-type, but instantiation yields a type

简言之,就是说你该用typename的地方没用typename,如以下代码

1 template<class Cont> void frontInsertion(Cont& ci) {

2     copy(a, a + sizeof(a)/sizeof(Cont::value_type),

3         front_inserter(ci));

4     copy(ci.begin(), ci.end(),

5         ostream_iterator<typename Cont::value_type>(

6             cout, " "));

7     cout << endl;

8 }

报错:

error: dependent-name ‘Cont:: value_type’ is parsed as a non-type, but instantiation yields a type

note: say ‘typename Cont:: value_type’ if a type is meant

解决办法:

在第2行的Cont::value_type改为typename Cont::value_type即可

 

备注:

上面的代码用MS VisualStudio自带的编译器编译不会报错,但是GCC会报错。

你可能感兴趣的:(parse)