workaround.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #ifndef BOOST_PREDEF_WORKAROUND_H
  8. #define BOOST_PREDEF_WORKAROUND_H
  9. /* tag::reference[]
  10. = `BOOST_PREDEF_WORKAROUND`
  11. [source]
  12. ----
  13. BOOST_PREDEF_WORKAROUND(symbol,comp,major,minor,patch)
  14. ----
  15. Usage:
  16. [source]
  17. ----
  18. #if BOOST_PREDEF_WORKAROUND(BOOST_COMP_CLANG,<,3,0,0)
  19. // Workaround for old clang compilers..
  20. #endif
  21. ----
  22. Defines a comparison against two version numbers that depends on the definion
  23. of `BOOST_STRICT_CONFIG`. When `BOOST_STRICT_CONFIG` is defined this will expand
  24. to a value convertible to `false`. Which has the effect of disabling all code
  25. conditionally guarded by `BOOST_PREDEF_WORKAROUND`. When `BOOST_STRICT_CONFIG`
  26. is undefine this expand to test the given `symbol` version value with the
  27. `comp` comparison against `BOOST_VERSION_NUMBER(major,minor,patch)`.
  28. */ // end::reference[]
  29. #ifdef BOOST_STRICT_CONFIG
  30. # define BOOST_PREDEF_WORKAROUND(symbol, comp, major, minor, patch) (0)
  31. #else
  32. # include <boost/predef/version_number.h>
  33. # define BOOST_PREDEF_WORKAROUND(symbol, comp, major, minor, patch) \
  34. ( (symbol) != (0) ) && \
  35. ( (symbol) comp (BOOST_VERSION_NUMBER( (major) , (minor) , (patch) )) )
  36. #endif
  37. /* tag::reference[]
  38. = `BOOST_PREDEF_TESTED_AT`
  39. [source]
  40. ----
  41. BOOST_PREDEF_TESTED_AT(symbol,major,minor,patch)
  42. ----
  43. Usage:
  44. [source]
  45. ----
  46. #if BOOST_PREDEF_TESTED_AT(BOOST_COMP_CLANG,3,5,0)
  47. // Needed for clang, and last checked for 3.5.0.
  48. #endif
  49. ----
  50. Defines a comparison against two version numbers that depends on the definion
  51. of `BOOST_STRICT_CONFIG` and `BOOST_DETECT_OUTDATED_WORKAROUNDS`.
  52. When `BOOST_STRICT_CONFIG` is defined this will expand to a value convertible
  53. to `false`. Which has the effect of disabling all code
  54. conditionally guarded by `BOOST_PREDEF_TESTED_AT`. When `BOOST_STRICT_CONFIG`
  55. is undefined this expand to either:
  56. * A value convertible to `true` when `BOOST_DETECT_OUTDATED_WORKAROUNDS` is not
  57. defined.
  58. * A value convertible `true` when the expansion of
  59. `BOOST_PREDEF_WORKAROUND(symbol, <=, major, minor, patch)` is `true` and
  60. `BOOST_DETECT_OUTDATED_WORKAROUNDS` is defined.
  61. * A compile error when the expansion of
  62. `BOOST_PREDEF_WORKAROUND(symbol, >, major, minor, patch)` is true and
  63. `BOOST_DETECT_OUTDATED_WORKAROUNDS` is defined.
  64. */ // end::reference[]
  65. #ifdef BOOST_STRICT_CONFIG
  66. # define BOOST_PREDEF_TESTED_AT(symbol, major, minor, patch) (0)
  67. #else
  68. # ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
  69. # define BOOST_PREDEF_TESTED_AT(symbol, major, minor, patch) ( \
  70. BOOST_PREDEF_WORKAROUND(symbol, <=, major, minor, patch) \
  71. ? 1 \
  72. : (1%0) )
  73. # else
  74. # define BOOST_PREDEF_TESTED_AT(symbol, major, minor, patch) \
  75. ( (symbol) >= BOOST_VERSION_NUMBER_AVAILABLE )
  76. # endif
  77. #endif
  78. #endif