由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - template
相关主题
where to define my template functionvector::iterator不对
C++ template请教一下这个template function在gcc下要怎么修改
C++ class template specialization questionthrust help ~~~
One c++ non-type template questionboost::function 的 syntax 问题
C++ optimization question这两个地方是否需要typename?
C++ template problemtemplate 类的继承问题
古德八你一次把需求写干净了[合集] Effecive c++ 真那么好? (转载)
C++ question about template typedefcompile error
相关话题的讨论汇总
话题: typename话题: template话题: iterator话题: vector话题: parameter
进入Programming版参与讨论
1 (共1页)
r*******y
发帖数: 1081
1
template void f(vector::iterator){}
this can not compile because of vector::iterator in the parameter
list. Why this parameter is not allowed here? Thanks.
t****t
发帖数: 6806
2
template void f(typename vector::iterator) {}

【在 r*******y 的大作中提到】
: template void f(vector::iterator){}
: this can not compile because of vector::iterator in the parameter
: list. Why this parameter is not allowed here? Thanks.

r*******y
发帖数: 1081
3
cool
we have to tell the compiler that vector::iterator is a typename
Thanks.

【在 t****t 的大作中提到】
: template void f(typename vector::iterator) {}
l*********s
发帖数: 5409
4
why the compiler cannot deduce it is a typename by itself? What is the
ambiguity there?

【在 r*******y 的大作中提到】
: cool
: we have to tell the compiler that vector::iterator is a typename
: Thanks.

t****t
发帖数: 6806
5
given type T, compiler can deduce. but when T is unknown, it can not.

【在 l*********s 的大作中提到】
: why the compiler cannot deduce it is a typename by itself? What is the
: ambiguity there?

l*********s
发帖数: 5409
6
Got it, thank you!

【在 t****t 的大作中提到】
: given type T, compiler can deduce. but when T is unknown, it can not.
S*******s
发帖数: 13043
7
with typename, it can.
without typename, it won't be taken as something else.
so, why typename here is a must? should they better make the typemane here
optional?

【在 t****t 的大作中提到】
: given type T, compiler can deduce. but when T is unknown, it can not.
t****t
发帖数: 6806
8
without keyword typename, by default it is member variable. if it is not
member variable, it is ill-formed.

【在 S*******s 的大作中提到】
: with typename, it can.
: without typename, it won't be taken as something else.
: so, why typename here is a must? should they better make the typemane here
: optional?

1 (共1页)
进入Programming版参与讨论
相关主题
compile errorC++ optimization question
template metaprogramming 的问题C++ template problem
C++ template questions古德八你一次把需求写干净了
C++ template preprocessorC++ question about template typedef
where to define my template functionvector::iterator不对
C++ template请教一下这个template function在gcc下要怎么修改
C++ class template specialization questionthrust help ~~~
One c++ non-type template questionboost::function 的 syntax 问题
相关话题的讨论汇总
话题: typename话题: template话题: iterator话题: vector话题: parameter