C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Template Unions.

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Dhruv
Guest





PostPosted: Sun Jan 25, 2004 1:44 am    Post subject: Template Unions. Reply with quote



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





PostPosted: Sun Jan 25, 2004 10:53 am    Post subject: Re: Template Unions. Reply with quote



"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





PostPosted: Tue Jan 27, 2004 3:01 pm    Post subject: Re: Template Unions. Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.