[Insight-users] using typename
Luis Ibanez
luis.ibanez at kitware.com
Tue Nov 30 17:52:20 EST 2004
Hi Bing,
The support/requirement for the "typename" keyword
varies largely among compilers.
To be more precise:
1) VC++ 6.0 Just don't care,
if you miss the use of "typename", the compiler
will not complaint. If you add "typename", the
compiler will simply ignore the keyword.
2) VC++ 7.0 (.NET) Will require it.
3) Gcc up to 3.2 requires the use of "typename"
and will complaint when you miss it. However
it tolerates the use of implicit typenames.
4) Gcc 3.3 if quite stringent. It requires "typename"
and does not tolerate implicite typenames anymore.
So, you better start using "typename" as required
by the C++ standard.
In general the rule is: typename is required when
you are in a templated class and you are trying to
access types (traits) from a classes that depends
on the template paramters.
For example:
template <class T>
class A
{
typedef typename T::Pointer TPointer;
};
There is a very particular occassion in which is was not
possible to unify the use of "typename" between multiple
compilers. This is when traits of one class are used as
default template paramters. For this very special case we
were forced to introduce the macro ITK_TYPENAME.
You will find the use of "typename" all over the toolkit
code and the applications. That will help you to get familiar
with the cases in which this keyword is expected.
Regards,
Luis
---------------------
Bing Jian wrote:
Hi,
It's an another C++ issue about usage of typename.
I write and debug my ITK program in visual studio, but
finally I have to move it to Sun and Linux, then compile
the code using g++. Seems g++ is always complaining
about my usage of typename. I have to add typename
at some places and remove typename at other locations.
Even the program finally compiles, I get lots of warnings
like
warning: implicit typename is deprecated
Do you guys have any experience on that? Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20041130/5b627a0d/attachment.htm
More information about the Insight-users
mailing list