[Insight-developers] itkStaticConstMacro and Explicit Instantiation
Brad King
brad.king at kitware.com
Mon, 26 Apr 2004 16:58:28 -0400
Jim,
I've been trying to introduce explicit instantiations in my working copy
of ITK, but I've run into a problem with itkStaticConstMacro. This
example demonstrates the problem:
template <int N>
struct A
{
static const unsigned int D = N;
typedef A<D> Self;
};
extern template struct A<2>;
When compiling with GCC 3.3, the compiler is walking through the
declarations of A<2> and marking them as do-not-instantiate. When it
gets to the typedef, it needs to access the definition of "D", but it is
not allowed to instantiate D and complains. If I replace the
declaration of D with an enumeration, it works.
If I remember correctly, we need the StaticConstMacro only because
Borland does not support using an enumeration. Since Borland does not
support extern template anyway, I propose that we change the macro to
use enum everywhere but borland.
Comments?
-Brad