On Jun 2, 2:42 pm, Pete Becker <p...@versatilecoding.comwrote:
andrew_n...@yahoo.com wrote:
Hi,
I'm using the latest version of Intel Linux Compiler, offers boost
built-in. I include <boost/type_traits/has_trivial_constructor.hpp>,
create a simple struct as follows:
struct MyStruct {
// no constructor!
};
and find that expression
boost::has_trivial_constructor<MyStruct>::value is false.
This is too wierd. Isn't that a bug in my boost package?
Nobody has figured out how to implement has_trivial_constructor without
compiler help. In TR1, it's allowed to always return false. That's
usually a safe fallback -- if you're using it to determine whether you
can use memcpy to initialize an array of that type, answering no means
you won't do any damage. (For more details, see chapter 11 of my book,
"The Standard C++ Library Extensions".)
Well that's good info! I know which classes of mine have trivial
constructors. For those, I inherit from an empty struct called
CtorDtorLess. I have gotten a meta-programming fragment from
Alexandrescu that uses a function with ... argument to distinguish
between structs that inherit from another struct versus not.
Unfortunately, on my compiler, I am getting a warning 1595 cannot pass
POD to elipses. Disabling that warning allows it to work.
Can you tell me what boost replacement there is for determining if a
struct inherits from another? I'm hoping I can use that instead and
avoid the warning.
Andy