Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-12-18 16:24:28


David Abrahams <dave_at_[hidden]> writes:
>
> I'd much prefer:
> BOOST_WORKAROUND(__SUNPRO_CC, BOOST_LATEST_VERSION(0x530))
>
> Which I think is easily achievable, no?
>
> # define BOOST_WORKAROUND(symbol, test) (symbol != 0) && (1 % ((symbol test) + 1))
> # ifdef BOOST_DETECT_OUTDATED
> # define BOOST_LATEST_VERSION(value) >value?-1:1
> # else
> # define BOOST_LATEST_VERSION(value) != 0
> # endif
>
> int x = 0;
>
> # if BOOST_WORKAROUND(COMPILER_VERSION, < 20)
> int y = 0;
> # elif BOOST_WORKAROUND(COMPILER_VERSION, BOOST_LATEST_VERSION(20))
> int z = 0;
> # endif
>
> This seems to work for everything but metrowerks, which says:
>
> ### mwcc Compiler:
> # File: foo.cpp
> # ----------------
> # 16: ( 21 != 0) && (1 % (( 21 >20?-1:1) + 1))
> # Error: ^
> # expression syntax error
>
>
> :(
>
> If anyone can come up with a workaround, I'd be psyched!

This does it:

    # define BOOST_WORKAROUND(symbol, test) (symbol != 0) && (1 % (( (symbol test) ) + 1))
    # ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
    # define BOOST_OPEN_PAREN (
    # define BOOST_CHECKED_AT(value) > value) ?(-1): BOOST_OPEN_PAREN 1
    # else
    # define BOOST_CHECKED_AT(value) != 0
    # endif

Now:

    # if BOOST_WORKAROUND(BOOST_MSVC, BOOST_CHECKED_AT(1300))

Seems to work as desired.

Any objections? I think I'm going to modify
boost/detail/workaround.hpp now.

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk