Boost logo

Boost :

From: Carl Daniel (cpdaniel_at_[hidden])
Date: 2001-11-20 13:02:59


----- Original Message -----
From: "Kevin S. Van Horn" <kevin.vanhorn_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, November 20, 2001 9:13 AM
Subject: Re: [boost] huge container types?

> On Tue, 20 Nov 2001, Carl Daniel wrote:
>
> > (btw - has anyone ever come up with an is_pod<T> solution?).
>
> Well, as a concept check, how about something like
>
> template <typename T>
> struct is_pod {
> typedef union { int x; T y; } foo;
> };
>
> Any instantiation of is_pod<T> for a non-POD type T should cause the
> compiler to reject the program.
>

Unfortunately, that's too restrictive. According to 9/4, a POD-struct "is an aggregate class that has no non-static
data members of type pointer-to-member, non-POD-struct, non-POD-union (or array of such types) or reference, and has no
used-defined copy-assignment operator and no user-defined destructor." **

While 9.5/1 says "...an object of a class with a non-trivial constructor... cannot be a member of a union".

So a class with a non-trivial default constructor might be a POD, but cannot be a member of a union :(

-cd

** Interesting that 9/4 doesn't mention anything about a POD not having any virtual member functions - is that covered
elsewhere?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk