|
Boost : |
From: Thyfate (thyfate_at_[hidden])
Date: 2006-04-06 13:50:56
The following program compiled with MSVC8 gives different results between
intrinsics and boost type traits (in the wrong sense: as if the type traits
library knew more about the classes than the compiler)
It seems to me this is related to a bug in MSVC8 intrinsics which should not
consider class two (see program below) as a POD type... The library should
thus not use the __is_pod intrinsics... though I can not find in the
standard a place where it is said that POD types should not have
constructors... (but then class one should also be of pod type)
Could someone please confirm/propose a fix?
Thanks in advance,
Charles-Antoine Giuliani
#include <iostream>
#include <boost/type_traits.hpp>
struct one
{
one()
:i(1)
{
}
int i;
};
struct two
{
one j;
};
#define F(a) #a << ": " << (a)
int main()
{
std::cout << F(__is_pod(one)) << '\n';
std::cout << F(boost::is_pod<one>::value) << '\n';
std::cout << '\n';
std::cout << F(__is_pod(two)) << '\n';
std::cout << F(boost::is_pod<two>::value) << '\n';
std::cout << '\n';
std::cout << F(__has_trivial_constructor(one)) << '\n';
std::cout << F(boost::has_trivial_constructor<one>::value) << '\n';
std::cout << '\n';
std::cout << F(__has_trivial_constructor(two)) << '\n';
std::cout << F(boost::has_trivial_constructor<two>::value) << '\n';
std::cout << '\n';
//Program output:
//__is_pod(one): 0
//boost::is_pod<one>::value: 0
//
//__is_pod(two): 1
//boost::is_pod<two>::value: 1
//
//__has_trivial_constructor(one): 0
//boost::has_trivial_constructor<one>::value: 0
//
//__has_trivial_constructor(two): 0
//boost::has_trivial_constructor<two>::value: 1
return 0;
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk