config.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // Copyright (c) 2016-2023 Antony Polukhin
  2. // Copyright (c) 2022 Denis Mikhailov
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_PFR_CONFIG_HPP
  7. #define BOOST_PFR_CONFIG_HPP
  8. #pragma once
  9. #if __cplusplus >= 201402L || (defined(_MSC_VER) && defined(_MSVC_LANG) && _MSC_VER > 1900)
  10. #include <type_traits> // to get non standard platform macro definitions (__GLIBCXX__ for example)
  11. #endif
  12. /// \file boost/pfr/config.hpp
  13. /// Contains all the macros that describe Boost.PFR configuration, like BOOST_PFR_ENABLED
  14. ///
  15. /// \note This header file doesn't require C++14 Standard and supports all C++ compilers, even pre C++14 compilers (C++11, C++03...).
  16. // Reminder:
  17. // * MSVC++ 14.2 _MSC_VER == 1927 <- Loophole is known to work (Visual Studio ????)
  18. // * MSVC++ 14.1 _MSC_VER == 1916 <- Loophole is known to NOT work (Visual Studio 2017)
  19. // * MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
  20. // * MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
  21. #ifdef BOOST_PFR_NOT_SUPPORTED
  22. # error Please, do not set BOOST_PFR_NOT_SUPPORTED value manually, use '-DBOOST_PFR_ENABLED=0' instead of it
  23. #endif
  24. #if defined(_MSC_VER)
  25. # if !defined(_MSVC_LANG) || _MSC_VER <= 1900
  26. # define BOOST_PFR_NOT_SUPPORTED 1
  27. # endif
  28. #elif __cplusplus < 201402L
  29. # define BOOST_PFR_NOT_SUPPORTED 1
  30. #endif
  31. #ifndef BOOST_PFR_USE_LOOPHOLE
  32. # if defined(_MSC_VER)
  33. # if _MSC_VER >= 1927
  34. # define BOOST_PFR_USE_LOOPHOLE 1
  35. # else
  36. # define BOOST_PFR_USE_LOOPHOLE 0
  37. # endif
  38. # elif defined(__clang_major__) && __clang_major__ >= 8
  39. # define BOOST_PFR_USE_LOOPHOLE 0
  40. # else
  41. # define BOOST_PFR_USE_LOOPHOLE 1
  42. # endif
  43. #endif
  44. #ifndef BOOST_PFR_USE_CPP17
  45. # ifdef __cpp_structured_bindings
  46. # define BOOST_PFR_USE_CPP17 1
  47. # elif defined(_MSVC_LANG)
  48. # if _MSVC_LANG >= 201703L
  49. # define BOOST_PFR_USE_CPP17 1
  50. # else
  51. # define BOOST_PFR_USE_CPP17 0
  52. # endif
  53. # else
  54. # define BOOST_PFR_USE_CPP17 0
  55. # endif
  56. #endif
  57. #if (!BOOST_PFR_USE_CPP17 && !BOOST_PFR_USE_LOOPHOLE)
  58. # if (defined(_MSC_VER) && _MSC_VER < 1916) ///< in Visual Studio 2017 v15.9 PFR library with classic engine normally works
  59. # define BOOST_PFR_NOT_SUPPORTED 1
  60. # endif
  61. #endif
  62. #ifndef BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE
  63. // Assume that libstdc++ since GCC-7.3 does not have linear instantiation depth in std::make_integral_sequence
  64. # if defined( __GLIBCXX__) && __GLIBCXX__ >= 20180101
  65. # define BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE 1
  66. # elif defined(_MSC_VER)
  67. # define BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE 1
  68. //# elif other known working lib
  69. # else
  70. # define BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE 0
  71. # endif
  72. #endif
  73. #ifndef BOOST_PFR_HAS_GUARANTEED_COPY_ELISION
  74. # if defined(__cpp_guaranteed_copy_elision) && (!defined(_MSC_VER) || _MSC_VER > 1928)
  75. # define BOOST_PFR_HAS_GUARANTEED_COPY_ELISION 1
  76. # else
  77. # define BOOST_PFR_HAS_GUARANTEED_COPY_ELISION 0
  78. # endif
  79. #endif
  80. #ifndef BOOST_PFR_ENABLE_IMPLICIT_REFLECTION
  81. # if defined(__cpp_lib_is_aggregate)
  82. # define BOOST_PFR_ENABLE_IMPLICIT_REFLECTION 1
  83. # else
  84. // There is no way to detect potential ability to be reflectable without std::is_aggregare
  85. # define BOOST_PFR_ENABLE_IMPLICIT_REFLECTION 0
  86. # endif
  87. #endif
  88. #if defined(__has_cpp_attribute)
  89. # if __has_cpp_attribute(maybe_unused)
  90. # define BOOST_PFR_MAYBE_UNUSED [[maybe_unused]]
  91. # endif
  92. #endif
  93. #ifndef BOOST_PFR_MAYBE_UNUSED
  94. # define BOOST_PFR_MAYBE_UNUSED
  95. #endif
  96. #ifndef BOOST_PFR_ENABLED
  97. # ifdef BOOST_PFR_NOT_SUPPORTED
  98. # define BOOST_PFR_ENABLED 0
  99. # else
  100. # define BOOST_PFR_ENABLED 1
  101. # endif
  102. #endif
  103. #undef BOOST_PFR_NOT_SUPPORTED
  104. #endif // BOOST_PFR_CONFIG_HPP