VC6 compatibility fixes

[SVN r20564]
This commit is contained in:
Fernando Cacciola
2003-10-30 14:45:13 +00:00
parent 65464ceffd
commit 9adda8450b
3 changed files with 39 additions and 5 deletions

View File

@ -19,8 +19,11 @@
#define BOOST_ENABLE_ASSERT_HANDLER
#include "boost/optional.hpp"
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
#include "boost/utility/in_place_factory.hpp"
#include "boost/utility/typed_in_place_factory.hpp"
#endif
#ifdef __BORLANDC__
#pragma hdrstop
@ -30,6 +33,7 @@
#include "optional_test_common.cpp"
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
struct A
{
A ( double a0, std::string a1 ) : m_a0(a0), m_a1(a1) {}
@ -48,7 +52,7 @@ int test_main( int, char* [] )
A a0(a00,a01);
A a1(a10,a11);
boost::optional<A> opt1(a0);
boost::optional<A> opt2 ( boost::in_place(a00,a01) ) ;
@ -61,13 +65,19 @@ int test_main( int, char* [] )
opt2 = boost::in_place(a10,a11);
BOOST_CHECK( *opt2 == a1 ) ;
opt3 = boost::in_place<A>(a10,a11);
BOOST_CHECK( *opt3 == a1 ) ;
return 0;
}
#else
int test_main( int, char* [] )
{
// If in-place factories are not supported there is nothing to test
return 0 ;
}
#endif

View File

@ -19,7 +19,10 @@
#define BOOST_ENABLE_ASSERT_HANDLER
#include "boost/optional.hpp"
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
#include "boost/utility/in_place_factory.hpp"
#endif
#ifdef __BORLANDC__
#pragma hdrstop
@ -29,6 +32,7 @@
#include "optional_test_common.cpp"
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
struct A
{
A ( double a0, std::string a1 ) : m_a0(a0), m_a1(a1) {}
@ -47,5 +51,13 @@ int test_main( int, char* [] )
return 0;
}
#else
int test_main( int, char* [] )
{
int invalid_extra_parameter ;
boost::optional<A> opt2 ( A(3.14,"pi",invalid_extra_parameter) ) ;
return 0;
}
#endif

View File

@ -19,7 +19,10 @@
#define BOOST_ENABLE_ASSERT_HANDLER
#include "boost/optional.hpp"
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
#include "boost/utility/typed_in_place_factory.hpp"
#endif
#ifdef __BORLANDC__
#pragma hdrstop
@ -29,6 +32,7 @@
#include "optional_test_common.cpp"
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
struct A
{
A ( double a0, std::string a1 ) : m_a0(a0), m_a1(a1) {}
@ -44,10 +48,18 @@ int test_main( int, char* [] )
{
// This must fail to compile.
// The first template argument to in_place<> is the target-type,
// not the first constructor parameter type.
// not the first constructor parameter type.
boost::optional<A> opt2 ( boost::in_place<int>(3.14,"pi") ) ;
return 0;
}
#else
int test_main( int, char* [] )
{
boost::optional<A> opt2 ( int(3.14) ) ;
return 0;
}
#endif