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