
This is another patch for a test case, as it is the test case that exploits the Borland bug. Essentially, BOOST_STATIC_CONSTANT cannot be used inside a member template on this compiler, so we need to fall back on using an enum in those cases. Updating the test case with this workaround shows that Borland can use the tested library correctly, so I would like to apply the patch to both mainline and rc_1_34_0 branch. -- AlisdairM cvs diff -u -wb -- numeric_traits_test.cpp (in directory E:\sourceforge\rc_1_34_0\boost\libs\utility\) Index: numeric_traits_test.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/utility/numeric_traits_test.cpp,v retrieving revision 1.13 diff -u -w -b -r1.13 numeric_traits_test.cpp --- numeric_traits_test.cpp 8 Dec 2005 03:20:42 -0000 1.13 +++ numeric_traits_test.cpp 19 Nov 2006 09:37:34 -0000 @@ -86,8 +86,13 @@ template <class Number> struct values { +#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x582) ) + enum { min = 0 }; + enum { max = UCHAR_MAX }; +#else BOOST_STATIC_CONSTANT(Number, min = 0); BOOST_STATIC_CONSTANT(Number, max = UCHAR_MAX); +#endif }; }; @@ -96,8 +101,13 @@ template <class Number> struct values { +#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x582) ) + enum { min = SCHAR_MIN }; + enum { max = SCHAR_MAX }; +#else BOOST_STATIC_CONSTANT(Number, min = SCHAR_MIN); BOOST_STATIC_CONSTANT(Number, max = SCHAR_MAX); +#endif }; }; @@ -108,11 +118,17 @@ template <class Number> struct traits { +#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x582) ) + enum { is_signed = boost::detail::is_signed<Number>::value ? true : false }; + enum { min = complement_base<is_signed>::template values<Number>::min }; + enum { max = complement_base<is_signed>::template values<Number>::max }; +#else BOOST_STATIC_CONSTANT(bool, is_signed = boost::detail::is_signed<Number>::value); BOOST_STATIC_CONSTANT(Number, min = complement_base<is_signed>::template values<Number>::min); BOOST_STATIC_CONSTANT(Number, max = complement_base<is_signed>::template values<Number>::max); +#endif }; };

Hi Alisdair,
This is another patch for a test case, as it is the test case that exploits the Borland bug.
Looks OK to me. Can you apply it yourself? Thank you! Best -- Fernando Cacciola SciSoft http://fcacciola.50webs.com/

On 11/19/06 4:53 AM, "AlisdairM" <alisdair.meredith@uk.renaultf1.com> wrote:
Isn't BOOST_STATIC_CONSTANT supposed to switch to an enum-based solution in those cases? Maybe the fix is to change the #defines that determine which implementation BOOST_STATIC_CONSTANT uses. Unless the problem is that the non-enum solution works in the same kinds of blocks that are not member class templates.
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com

Daryle Walker wrote:
Yes, it does do so for Borland already, however the argument to BOOST_STATIC_ASSERT still has to be something that the Borland compiler can cope with. The usual culprit is something like: template <class T> void foo(T) { BOOST_STATIC_CONSTANT(int, value = something); BOOST_STATIC_ASSERT(value > 1); // fails on Borland as do all other uses of value *within this scope* } John.
participants (4)
-
AlisdairM
-
Daryle Walker
-
Fernando Cacciola
-
John Maddock