From 9adda8450bb95e06a850637fd46375c408d9fb24 Mon Sep 17 00:00:00 2001 From: Fernando Cacciola Date: Thu, 30 Oct 2003 14:45:13 +0000 Subject: [PATCH] VC6 compatibility fixes [SVN r20564] --- test/optional_test_inplace.cpp | 18 ++++++++++++++---- test/optional_test_inplace_fail.cpp | 12 ++++++++++++ test/optional_test_inplace_fail2.cpp | 14 +++++++++++++- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/test/optional_test_inplace.cpp b/test/optional_test_inplace.cpp index 2eb0113..6e90a67 100644 --- a/test/optional_test_inplace.cpp +++ b/test/optional_test_inplace.cpp @@ -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 opt1(a0); boost::optional 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(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 diff --git a/test/optional_test_inplace_fail.cpp b/test/optional_test_inplace_fail.cpp index 7a88365..da6c5a9 100644 --- a/test/optional_test_inplace_fail.cpp +++ b/test/optional_test_inplace_fail.cpp @@ -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 opt2 ( A(3.14,"pi",invalid_extra_parameter) ) ; + return 0; +} +#endif diff --git a/test/optional_test_inplace_fail2.cpp b/test/optional_test_inplace_fail2.cpp index 65d4efb..87a613a 100644 --- a/test/optional_test_inplace_fail2.cpp +++ b/test/optional_test_inplace_fail2.cpp @@ -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 opt2 ( boost::in_place(3.14,"pi") ) ; return 0; } +#else +int test_main( int, char* [] ) +{ + boost::optional opt2 ( int(3.14) ) ; + + return 0; +} +#endif