From 721764937f7b41971561d025c562e1727aa2ead5 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sat, 19 Jan 2008 20:21:18 +0000 Subject: [PATCH] value_init_test now works around Borland 5.82 bug ("Error E2015: Ambiguity..." when using initialized_value), that is fixed with a newer compiler version [SVN r42868] --- value_init_test.cpp | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/value_init_test.cpp b/value_init_test.cpp index 70cd998..175d30c 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -6,8 +6,8 @@ // // Test program for "boost/utility/value_init.hpp" // -// 21 Agu 2002 (Created) Fernando Cacciola -// 16 Jan 2008 (Added tests regarding compiler issues and initialized_value) Fernando Cacciola, Niels Dekker +// 21 Ago 2002 (Created) Fernando Cacciola +// 19 Jan 2008 (Added tests regarding compiler issues and initialized_value) Fernando Cacciola, Niels Dekker #include // For memcmp. #include @@ -180,6 +180,32 @@ struct CopyFunctionCallTester }; +template +void check_initialized_value ( T const& y ) +{ + T initializedValue = boost::initialized_value() ; + BOOST_CHECK ( y == initializedValue ) ; +} + +#ifdef __BORLANDC__ +#if __BORLANDC__ == 0x582 +void check_initialized_value( NonPOD const& ) +{ + // The initialized_value check is skipped for Borland 5.82 + // and this type (NonPOD), because the following statement + // won't compile on this particular compiler version: + // NonPOD initializedValue = boost::initialized_value() ; + // + // This is caused by a compiler bug, that is fixed with a newer version + // of the Borland compiler. The Release Notes for Delphi(R) 2007 for + // Win32(R) and C++Builder(R) 2007 (http://dn.codegear.com/article/36575) + // say about similar statements: + // both of these statements now compile but under 5.82 got the error: + // Error E2015: Ambiguity between 'V::V(const A &)' and 'V::V(const V &)' +} +#endif +#endif + // // This test function tests boost::value_initialized for a specific type T. // The first argument (y) is assumed have the value of a value-initialized object. @@ -189,13 +215,13 @@ template bool test ( T const& y, T const& z ) { const boost::unit_test::counter_t counter_before_test = boost::minimal_test::errors_counter(); + + check_initialized_value(y); + boost::value_initialized x ; BOOST_CHECK ( y == x ) ; BOOST_CHECK ( y == boost::get(x) ) ; - T initializedValue = boost::initialized_value() ; - BOOST_CHECK ( y == initializedValue ) ; - static_cast(x) = z ; boost::get(x) = z ; BOOST_CHECK ( x == z ) ;