1 /*
2 Copyright Rene Rivera 2017
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt)
6 */
7 
8 #ifndef BOOST_PREDEF_WORKAROUND_H
9 #define BOOST_PREDEF_WORKAROUND_H
10 
11 /* tag::reference[]
12 
13 = `BOOST_PREDEF_WORKAROUND`
14 
15 [source]
16 ----
17 BOOST_PREDEF_WORKAROUND(symbol,comp,major,minor,patch)
18 ----
19 
20 Usage:
21 
22 [source]
23 ----
24 #if BOOST_PREDEF_WORKAROUND(BOOST_COMP_CLANG,<,3,0,0)
25     // Workaround for old clang compilers..
26 #endif
27 ----
28 
29 Defines a comparison against two version numbers that depends on the definion
30 of `BOOST_STRICT_CONFIG`. When `BOOST_STRICT_CONFIG` is defined this will expand
31 to a value convertible to `false`. Which has the effect of disabling all code
32 conditionally guarded by `BOOST_PREDEF_WORKAROUND`. When `BOOST_STRICT_CONFIG`
33 is undefine this expand to test the given `symbol` version value with the
34 `comp` comparison against `BOOST_VERSION_NUMBER(major,minor,patch)`.
35 
36 */ // end::reference[]
37 #ifdef BOOST_STRICT_CONFIG
38 #   define BOOST_PREDEF_WORKAROUND(symbol, comp, major, minor, patch) (0)
39 #else
40 #   include <boost/predef/version_number.h>
41 #   define BOOST_PREDEF_WORKAROUND(symbol, comp, major, minor, patch) \
42         ( (symbol) != (0) ) && \
43         ( (symbol) comp (BOOST_VERSION_NUMBER( (major) , (minor) , (patch) )) )
44 #endif
45 
46 /* tag::reference[]
47 
48 = `BOOST_PREDEF_TESTED_AT`
49 
50 [source]
51 ----
52 BOOST_PREDEF_TESTED_AT(symbol,major,minor,patch)
53 ----
54 
55 Usage:
56 
57 [source]
58 ----
59 #if BOOST_PREDEF_TESTED_AT(BOOST_COMP_CLANG,3,5,0)
60     // Needed for clang, and last checked for 3.5.0.
61 #endif
62 ----
63 
64 Defines a comparison against two version numbers that depends on the definion
65 of `BOOST_STRICT_CONFIG` and `BOOST_DETECT_OUTDATED_WORKAROUNDS`.
66 When `BOOST_STRICT_CONFIG` is defined this will expand to a value convertible
67 to `false`. Which has the effect of disabling all code
68 conditionally guarded by `BOOST_PREDEF_TESTED_AT`. When `BOOST_STRICT_CONFIG`
69 is undefined this expand to either:
70 
71 * A value convertible to `true` when `BOOST_DETECT_OUTDATED_WORKAROUNDS` is not
72   defined.
73 * A value convertible `true` when the expansion of
74   `BOOST_PREDEF_WORKAROUND(symbol, <=, major, minor, patch)` is `true` and
75   `BOOST_DETECT_OUTDATED_WORKAROUNDS` is defined.
76 * A compile error when the expansion of
77   `BOOST_PREDEF_WORKAROUND(symbol, >, major, minor, patch)` is true and
78   `BOOST_DETECT_OUTDATED_WORKAROUNDS` is defined.
79 
80 */ // end::reference[]
81 #ifdef BOOST_STRICT_CONFIG
82 #   define BOOST_PREDEF_TESTED_AT(symbol, major, minor, patch) (0)
83 #else
84 #   ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
85 #       define BOOST_PREDEF_TESTED_AT(symbol, major, minor, patch) ( \
86             BOOST_PREDEF_WORKAROUND(symbol, <=, major, minor, patch) \
87             ? 1 \
88             : (1%0) )
89 #   else
90 #       define BOOST_PREDEF_TESTED_AT(symbol, major, minor, patch) \
91             ( (symbol) >= BOOST_VERSION_NUMBER_AVAILABLE )
92 #   endif
93 #endif
94 
95 #endif
96