| View previous topic :: View next topic |
| Author |
Message |
Dhruv Guest
|
Posted: Sun Jan 25, 2004 1:44 am Post subject: Template Unions. |
|
|
Is this legal Code? g++3.2 Complains...
template <typename T>
struct Foo {
template <size_t Size>
union Node {
union Node *next;
char Data[Size];
};
enum { Test = 8 };
static Node<(sizeof(T) * Test)> *n4;
};
template <typename T>
Foo<T>::Node<(sizeof(T) * Foo *Foo<T>::n4;
int main ()
{
Foo<int> _f;
}
Regards,
-Dhruv.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Gabriel Dos Reis Guest
|
Posted: Sun Jan 25, 2004 10:53 am Post subject: Re: Template Unions. |
|
|
"Dhruv" <dhruvbird (AT) gmx (DOT) net> writes:
| Quote: | Is this legal Code? g++3.2 Complains...
template <typename T
struct Foo {
template
union Node {
union Node *next;
char Data[Size];
};
enum { Test = 8 };
static Node<(sizeof(T) * Test)> *n4;
};
template <typename T
Foo *Foo<T>::n4;
|
Does this have anything to do with unions? I guess you get the same
kind of complaints with
template<class>
struct X {
enum { S = 8 };
static char buf[sizeof (T) * S];
};
template<class T>
char X<T>::buf[sizeof (T) * X<T>::S];
I thought Mark Mitchell submitted a DR along those lines, but I'm
unable to find it right now.
--
Gabriel Dos Reis
[email]gdr (AT) integrable-solutions (DOT) net[/email]
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
llewelly Guest
|
Posted: Tue Jan 27, 2004 3:01 pm Post subject: Re: Template Unions. |
|
|
Gabriel Dos Reis <gdr (AT) integrable-solutions (DOT) net> writes:
[snip]
| Quote: | Does this have anything to do with unions? I guess you get the same
kind of complaints with
template<class
struct X {
enum { S = 8 };
static char buf[sizeof (T) * S];
};
template
char X
I thought Mark Mitchell submitted a DR along those lines, but I'm
unable to find it right now.
[snip] |
Maybe this one:
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html#408
?
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|