[Insight-developers] typename platform conflict
Miller, James V (CRD)
millerjv@crd.ge.com
Tue, 13 Mar 2001 17:53:24 -0500
Can we solve this by inserting a dummy class, so the code would look like
template<type T>
class DummyTrait
{
typedef T::SomeType SomeType;
}
typename<class T1, class T2 = DummyTrait<T1>::SomeType>
class X{}
instead of using a macro. (Can you tell I hate macros....)
-----Original Message-----
From: Brad King [mailto:brad.king@kitware.com]
Sent: Tuesday, March 13, 2001 4:59 PM
To: Insight Developers
Subject: [Insight-developers] typename platform conflict
Hello, all:
Well, at long last we have encountered a situation in which the
intersection of the capabilities of all our compilers is the empty
set. We will have to use a macro to resolve this one.
The problem occurs when a typename type is used in a default template
argument:
typename <class T1, class T2 = typename T1::SomeType>
class X {};
SGI's MIPSpro will not accept this code without the typename keyword.
MSVC will not accept this code unless the typename keyword is missing.
I have added a macro definition to itkWin32Header.h:
#define TYPENAME typename
in the case of MSVC, the macro will be defined as
#define TYPENAME
The new code for the above example is
typename <class T1, class T2 = TYPENAME T1::SomeType>
class X {};
This macro should ONLY be used for default template arguments. It should
NEVER be used in place of plain old "typename" in other situations. If
anyone has another problem for which you think you need the TYPENAME
macro, post it to this list first for discussion.
Also, now would be a good time to discuss the name of this
macro. TYPENAME is minimally disruptive to reading the code, but may
mislead people into using it when it should not be used (not to mention
name conflicts with other libraries). We might want to consider
ITK_DEFAULT_ARGUMENT_TYPENAME instead. Anyone have thoughts on this?
-Brad
_______________________________________________
Insight-developers mailing list
Insight-developers@public.kitware.com
http://public.kitware.com/mailman/listinfo/insight-developers