optional_config.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal.
  2. // Copyright (C) 2015 - 2017 Andrzej Krzemienski.
  3. //
  4. // Use, modification, and distribution is subject to the Boost Software
  5. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // See http://www.boost.org/libs/optional for documentation.
  9. //
  10. // You are welcome to contact the author at:
  11. // akrzemi1@gmail.com
  12. #ifndef BOOST_OPTIONAL_DETAIL_OPTIONAL_CONFIG_AJK_28JAN2015_HPP
  13. #define BOOST_OPTIONAL_DETAIL_OPTIONAL_CONFIG_AJK_28JAN2015_HPP
  14. #include <boost/config.hpp>
  15. #include <boost/detail/workaround.hpp>
  16. #if (defined BOOST_NO_CXX11_RVALUE_REFERENCES) || (defined BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES)
  17. # define BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
  18. #endif
  19. #if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION,<=700)
  20. // AFAICT only Intel 7 correctly resolves the overload set
  21. // that includes the in-place factory taking functions,
  22. // so for the other icc versions, in-place factory support
  23. // is disabled
  24. # define BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
  25. #endif
  26. #if BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x551)
  27. // BCB (5.5.1) cannot parse the nested template struct in an inplace factory.
  28. # define BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
  29. #endif
  30. #if !defined(BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT) \
  31. && defined BOOST_BCB_PARTIAL_SPECIALIZATION_BUG
  32. // BCB (up to 5.64) has the following bug:
  33. // If there is a member function/operator template of the form
  34. // template<class Expr> mfunc( Expr expr ) ;
  35. // some calls are resolved to this even if there are other better matches.
  36. // The effect of this bug is that calls to converting ctors and assignments
  37. // are incorrectly sink to this general catch-all member function template as shown above.
  38. # define BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION
  39. #endif
  40. #if !defined(BOOST_NO_MAY_ALIAS)
  41. // GCC since 3.3 and some other compilers have may_alias attribute that helps to alleviate
  42. // optimizer issues with regard to violation of the strict aliasing rules. The optional< T >
  43. // storage type is marked with this attribute in order to let the compiler know that it will
  44. // alias objects of type T and silence compilation warnings.
  45. # define BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS
  46. #endif
  47. #if (defined(_MSC_VER) && _MSC_VER <= 1800)
  48. // on MSCV 2013 and earlier an unwanted temporary is created when you assign from
  49. // a const lvalue of integral type. Thus we bind not to the original address but
  50. // to a temporary.
  51. # define BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
  52. #endif
  53. #if (defined __GNUC__) && (!defined BOOST_INTEL_CXX_VERSION) && (!defined __clang__)
  54. // On some GCC versions an unwanted temporary is created when you copy-initialize
  55. // from a const lvalue of integral type. Thus we bind not to the original address but
  56. // to a temporary.
  57. # if (__GNUC__ < 4)
  58. # define BOOST_OPTIONAL_CONFIG_NO_PROPER_CONVERT_FROM_CONST_INT
  59. # endif
  60. # if (__GNUC__ == 4 && __GNUC_MINOR__ <= 5)
  61. # define BOOST_OPTIONAL_CONFIG_NO_PROPER_CONVERT_FROM_CONST_INT
  62. # endif
  63. # if (__GNUC__ == 5 && __GNUC_MINOR__ < 2)
  64. # define BOOST_OPTIONAL_CONFIG_NO_PROPER_CONVERT_FROM_CONST_INT
  65. # endif
  66. # if (__GNUC__ == 5 && __GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ == 0)
  67. # define BOOST_OPTIONAL_CONFIG_NO_PROPER_CONVERT_FROM_CONST_INT
  68. # endif
  69. #endif // defined(__GNUC__)
  70. #if (defined __GNUC__) && (!defined BOOST_NO_CXX11_RVALUE_REFERENCES)
  71. // On some initial rvalue reference implementations GCC does it in a strange way,
  72. // preferring perfect-forwarding constructor to implicit copy constructor.
  73. # if (__GNUC__ == 4 && __GNUC_MINOR__ == 4)
  74. # define BOOST_OPTIONAL_CONFIG_NO_LEGAL_CONVERT_FROM_REF
  75. # endif
  76. # if (__GNUC__ == 4 && __GNUC_MINOR__ == 5)
  77. # define BOOST_OPTIONAL_CONFIG_NO_LEGAL_CONVERT_FROM_REF
  78. # endif
  79. #endif // defined(__GNUC__)
  80. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800) && !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40500) && !defined(__SUNPRO_CC)
  81. // this condition is a copy paste from is_constructible.hpp
  82. // I also disable SUNPRO, as it seems not to support type_traits correctly
  83. #else
  84. # define BOOST_OPTIONAL_DETAIL_NO_IS_CONSTRUCTIBLE_TRAIT
  85. #endif
  86. #if defined __SUNPRO_CC
  87. # define BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS
  88. #elif (defined _MSC_FULL_VER) && (_MSC_FULL_VER < 190023026)
  89. # define BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS
  90. #elif defined BOOST_GCC && !defined BOOST_GCC_CXX11
  91. # define BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS
  92. #elif defined BOOST_GCC_VERSION && BOOST_GCC_VERSION < 40800
  93. # define BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS
  94. #endif
  95. // Detect suport for defaulting move operations
  96. // (some older compilers implement rvalue references,
  97. // defaulted funcitons but move operations are not special members and cannot be defaulted)
  98. #ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
  99. # define BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_MOVE_FUNCTIONS
  100. #elif BOOST_WORKAROUND(BOOST_MSVC, < 1900)
  101. # define BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_MOVE_FUNCTIONS
  102. #elif BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40600)
  103. # define BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_MOVE_FUNCTIONS
  104. #endif
  105. #ifdef BOOST_OPTIONAL_CONFIG_NO_DIRECT_STORAGE_SPEC
  106. # define BOOST_OPTIONAL_DETAIL_NO_DIRECT_STORAGE_SPEC
  107. #endif
  108. #endif // header guard