Is it possible to determine if a structure is non-POD?

H

hovik

Is there a way to determine at run-time (or maybe at compile-time)
that a given class is a POD structure or it has a constructor, without
generating compiler errors?

Let's say I have a template T that takes class X as an argument, and I
want to have a clear test that tells me if X is POD or not.

Thanks,
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

Is there a way to determine at run-time (or maybe at compile-time)
that a given class is a POD structure or it has a constructor, without
generating compiler errors?

Let's say I have a template T that takes class X as an argument, and I
want to have a clear test that tells me if X is POD or not.

There's something like that in Boost, search for is_pod.
 
J

John Harrison

Erik said:
There's something like that in Boost, search for is_pod.

Unfortunate boost::is_pod doesn't work. To quote from the boost
documentation

Without some (as yet unspecified) help from the compiler, is_pod will
never report that a class or struct is a POD; this is always safe, if
possibly sub-optimal. Currently (May 2005) only MWCW 9 and Visual C++ 8
have the necessary compiler-intrinsics.

For 'sub-optimal' read 'doesn't work'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top