Merge from trunk.

[SVN r40260]
This commit is contained in:
Daniel James
2007-10-21 07:28:23 +00:00
parent 561a94c8c6
commit 6af8e5d5f9
2 changed files with 33 additions and 0 deletions

View File

@@ -31,6 +31,16 @@
#include <cstring>
#include <new>
#ifdef BOOST_MSVC
#pragma warning(push)
#if _MSC_VER >= 1310
// When using MSVC 7.1 or higher, placement new, "new (&x) T()", may trigger warning C4345:
// "behavior change: an object of POD type constructed with an initializer of the form ()
// will be default-initialized". There is no need to worry about this, though.
#pragma warning(disable: 4345)
#endif
#endif
namespace boost {
namespace vinit_detail {
@@ -89,6 +99,11 @@ class non_const_T_base
mutable typename ::boost::aligned_storage<sizeof(T), ::boost::alignment_of<T>::value>::type x;
} ;
#ifdef BOOST_MSVC
// Restores the state of warning C4345.
#pragma warning(pop)
#endif
#else
namespace boost {

View File

@@ -60,6 +60,20 @@ struct NonPOD : NonPODBase
std::string id ;
} ;
//
// Sample aggregate POD struct type
//
struct AggregatePODStruct
{
float f;
char c;
int i;
};
bool operator == ( AggregatePODStruct const& lhs, AggregatePODStruct const& rhs )
{ return lhs.f == rhs.f && lhs.c == rhs.c && lhs.i == rhs.i ; }
template<class T>
void test ( T const& y, T const& z )
{
@@ -98,6 +112,10 @@ int test_main(int, char **)
NonPOD NonPOD_object( std::string("NonPOD_object") );
test<NonPOD *>( 0, &NonPOD_object ) ;
AggregatePODStruct zeroInitializedAggregatePODStruct = { 0.0f, '\0', 0 };
AggregatePODStruct nonZeroInitializedAggregatePODStruct = { 1.25f, 'a', -1 };
test(zeroInitializedAggregatePODStruct, nonZeroInitializedAggregatePODStruct);
return 0;
}