os/ossrv/ossrv_pub/boost_apis/boost/detail/workaround.hpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright David Abrahams 2002.
sl@0
     2
// Distributed under the Boost Software License, Version 1.0. (See
sl@0
     3
// accompanying file LICENSE_1_0.txt or copy at
sl@0
     4
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
     5
#ifndef WORKAROUND_DWA2002126_HPP
sl@0
     6
# define WORKAROUND_DWA2002126_HPP
sl@0
     7
sl@0
     8
// Compiler/library version workaround macro
sl@0
     9
//
sl@0
    10
// Usage:
sl@0
    11
//
sl@0
    12
//     #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
sl@0
    13
//        // workaround for eVC4 and VC6
sl@0
    14
//        ... // workaround code here
sl@0
    15
//     #endif
sl@0
    16
//
sl@0
    17
// When BOOST_STRICT_CONFIG is defined, expands to 0. Otherwise, the
sl@0
    18
// first argument must be undefined or expand to a numeric
sl@0
    19
// value. The above expands to:
sl@0
    20
//
sl@0
    21
//     (BOOST_MSVC) != 0 && (BOOST_MSVC) < 1300
sl@0
    22
//
sl@0
    23
// When used for workarounds that apply to the latest known version 
sl@0
    24
// and all earlier versions of a compiler, the following convention 
sl@0
    25
// should be observed:
sl@0
    26
//
sl@0
    27
//     #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1301))
sl@0
    28
//
sl@0
    29
// The version number in this case corresponds to the last version in
sl@0
    30
// which the workaround was known to have been required. When
sl@0
    31
// BOOST_DETECT_OUTDATED_WORKAROUNDS is not the defined, the macro
sl@0
    32
// BOOST_TESTED_AT(x) expands to "!= 0", which effectively activates
sl@0
    33
// the workaround for any version of the compiler. When
sl@0
    34
// BOOST_DETECT_OUTDATED_WORKAROUNDS is defined, a compiler warning or
sl@0
    35
// error will be issued if the compiler version exceeds the argument
sl@0
    36
// to BOOST_TESTED_AT().  This can be used to locate workarounds which
sl@0
    37
// may be obsoleted by newer versions.
sl@0
    38
sl@0
    39
# ifndef BOOST_STRICT_CONFIG
sl@0
    40
sl@0
    41
#  define BOOST_WORKAROUND(symbol, test)                \
sl@0
    42
        ((symbol != 0) && (1 % (( (symbol test) ) + 1)))
sl@0
    43
//                              ^ ^           ^ ^
sl@0
    44
// The extra level of parenthesis nesting above, along with the
sl@0
    45
// BOOST_OPEN_PAREN indirection below, is required to satisfy the
sl@0
    46
// broken preprocessor in MWCW 8.3 and earlier.
sl@0
    47
//
sl@0
    48
// The basic mechanism works as follows:
sl@0
    49
//      (symbol test) + 1        =>   if (symbol test) then 2 else 1
sl@0
    50
//      1 % ((symbol test) + 1)  =>   if (symbol test) then 1 else 0
sl@0
    51
//
sl@0
    52
// The complication with % is for cooperation with BOOST_TESTED_AT().
sl@0
    53
// When "test" is BOOST_TESTED_AT(x) and
sl@0
    54
// BOOST_DETECT_OUTDATED_WORKAROUNDS is #defined,
sl@0
    55
//
sl@0
    56
//      symbol test              =>   if (symbol <= x) then 1 else -1
sl@0
    57
//      (symbol test) + 1        =>   if (symbol <= x) then 2 else 0
sl@0
    58
//      1 % ((symbol test) + 1)  =>   if (symbol <= x) then 1 else divide-by-zero
sl@0
    59
//
sl@0
    60
sl@0
    61
#  ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
sl@0
    62
#   define BOOST_OPEN_PAREN (
sl@0
    63
#   define BOOST_TESTED_AT(value)  > value) ?(-1): BOOST_OPEN_PAREN 1
sl@0
    64
#  else
sl@0
    65
#   define BOOST_TESTED_AT(value) != ((value)-(value))
sl@0
    66
#  endif
sl@0
    67
sl@0
    68
# else
sl@0
    69
sl@0
    70
#  define BOOST_WORKAROUND(symbol, test) 0
sl@0
    71
sl@0
    72
# endif 
sl@0
    73
sl@0
    74
#endif // WORKAROUND_DWA2002126_HPP