Re: Template problem
- From: "John Carson" <jcarson_n_o_sp_am_@xxxxxxxxxxxxxxx>
- Date: Sat, 11 Nov 2006 11:31:05 +1100
"Jens Mander" <jens@xxxxxxxxxx> wrote in message
news:OaXCBvRBHHA.1012@xxxxxxxxxxxxxxxxxxxx
The following code generates errors when compiled using VC++ 7.1.
However, gcc 3.2.2 and comeau online have no problems with it. Is
this illegal code or a compiler bug? If it is the latter; was it
fixed in the latest release of VC++? Are there any workarounds for my
version?
Thank you in advance!
====================
template <typename T>
struct Outer
{
template <T value = 0>
struct Inner {};
};
int main ()
{
Outer<int>::Inner<> fail;
}
1. I'm guessing it is a bug.
2. No, it hasn't been fixed.
3. A workaround is to only forward declare the Inner class when you declare
the Outer class, and to add the full declaration of Inner later.
template <typename T>
struct Outer
{
// forward declare
template <T value = 0>
struct Inner;
};
// complete the declaration
template <typename T>
template<T value>
struct Outer<T>::Inner<value>
{};
int main ()
{
Outer<int>::Inner<> fail;
return 0;
}
--
John Carson
.
- References:
- Template problem
- From: Jens Mander
- Template problem
- Prev by Date: Re: Is PGO (Profile Guided Optimization) incompatible with stl and /MD
- Next by Date: Re: Is PGO (Profile Guided Optimization) incompatible with stl and /MD
- Previous by thread: Template problem
- Next by thread: Re: Is PGO (Profile Guided Optimization) incompatible with stl and /MD
- Index(es):
Relevant Pages
|