config.hpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // Copyright (c) 2016-2025 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 !defined(BOOST_USE_MODULES) && (__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. #if defined(BOOST_USE_MODULES) || __cplusplus >= 202002L
  13. #include <version>
  14. #endif
  15. /// \file boost/pfr/config.hpp
  16. /// Contains all the macros that describe Boost.PFR configuration, like BOOST_PFR_ENABLED
  17. ///
  18. /// \note This header file doesn't require C++14 Standard and supports all C++ compilers, even pre C++14 compilers (C++11, C++03...).
  19. // Reminder:
  20. // * MSVC++ 14.2 _MSC_VER == 1927 <- Loophole is known to work (Visual Studio ????)
  21. // * MSVC++ 14.1 _MSC_VER == 1916 <- Loophole is known to NOT work (Visual Studio 2017)
  22. // * MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
  23. // * MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
  24. #ifdef BOOST_PFR_NOT_SUPPORTED
  25. # error Please, do not set BOOST_PFR_NOT_SUPPORTED value manually, use '-DBOOST_PFR_ENABLED=0' instead of it
  26. #endif
  27. #if defined(_MSC_VER)
  28. # if !defined(_MSVC_LANG) || _MSC_VER <= 1900
  29. # define BOOST_PFR_NOT_SUPPORTED 1
  30. # endif
  31. #elif __cplusplus < 201402L
  32. # define BOOST_PFR_NOT_SUPPORTED 1
  33. #endif
  34. #ifndef BOOST_PFR_USE_LOOPHOLE
  35. # if defined(_MSC_VER)
  36. # if _MSC_VER >= 1927
  37. # define BOOST_PFR_USE_LOOPHOLE 1
  38. # else
  39. # define BOOST_PFR_USE_LOOPHOLE 0
  40. # endif
  41. # elif defined(__clang_major__) && __clang_major__ >= 8
  42. # define BOOST_PFR_USE_LOOPHOLE 0
  43. # else
  44. # define BOOST_PFR_USE_LOOPHOLE 1
  45. # endif
  46. #endif
  47. #ifndef BOOST_PFR_USE_CPP26
  48. #if __cpp_structured_bindings >= 202411L && __cpp_lib_forward_like >= 202207L
  49. #define BOOST_PFR_USE_CPP26 1
  50. #else
  51. #define BOOST_PFR_USE_CPP26 0
  52. #endif
  53. #endif
  54. #ifndef BOOST_PFR_USE_CPP17
  55. # ifdef __cpp_structured_bindings
  56. # define BOOST_PFR_USE_CPP17 1
  57. # elif defined(_MSVC_LANG)
  58. # if _MSVC_LANG >= 201703L
  59. # define BOOST_PFR_USE_CPP17 1
  60. # else
  61. # define BOOST_PFR_USE_CPP17 0
  62. # endif
  63. # else
  64. # define BOOST_PFR_USE_CPP17 0
  65. # endif
  66. #endif
  67. #if (!BOOST_PFR_USE_CPP26 && !BOOST_PFR_USE_CPP17 && !BOOST_PFR_USE_LOOPHOLE)
  68. # if (defined(_MSC_VER) && _MSC_VER < 1916) ///< in Visual Studio 2017 v15.9 PFR library with classic engine normally works
  69. # define BOOST_PFR_NOT_SUPPORTED 1
  70. # endif
  71. #endif
  72. #ifndef BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE
  73. # if defined(BOOST_USE_MODULES)
  74. # define BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE 1
  75. // Assume that libstdc++ since GCC-7.3 does not have linear instantiation depth in std::make_integral_sequence
  76. # elif defined( __GLIBCXX__) && __GLIBCXX__ >= 20180101
  77. # define BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE 1
  78. # elif defined(_MSC_VER)
  79. # define BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE 1
  80. //# elif other known working lib
  81. # else
  82. # define BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE 0
  83. # endif
  84. #endif
  85. #ifndef BOOST_PFR_HAS_GUARANTEED_COPY_ELISION
  86. # if defined(__cpp_guaranteed_copy_elision) && (!defined(_MSC_VER) || _MSC_VER > 1928)
  87. # define BOOST_PFR_HAS_GUARANTEED_COPY_ELISION 1
  88. # else
  89. # define BOOST_PFR_HAS_GUARANTEED_COPY_ELISION 0
  90. # endif
  91. #endif
  92. #ifndef BOOST_PFR_ENABLE_IMPLICIT_REFLECTION
  93. # if defined(__cpp_lib_is_aggregate)
  94. # define BOOST_PFR_ENABLE_IMPLICIT_REFLECTION 1
  95. # else
  96. // There is no way to detect potential ability to be reflectable without std::is_aggregare
  97. # define BOOST_PFR_ENABLE_IMPLICIT_REFLECTION 0
  98. # endif
  99. #endif
  100. #ifndef BOOST_PFR_CORE_NAME_ENABLED
  101. # if (__cplusplus >= 202002L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 202002L))
  102. # if (defined(__cpp_nontype_template_args) && __cpp_nontype_template_args >= 201911) \
  103. || (defined(__clang_major__) && __clang_major__ >= 12)
  104. # define BOOST_PFR_CORE_NAME_ENABLED 1
  105. # else
  106. # define BOOST_PFR_CORE_NAME_ENABLED 0
  107. # endif
  108. # else
  109. # define BOOST_PFR_CORE_NAME_ENABLED 0
  110. # endif
  111. #endif
  112. #ifndef BOOST_PFR_CORE_NAME_PARSING
  113. # if defined(_MSC_VER) && !defined(__clang__)
  114. # define BOOST_PFR_CORE_NAME_PARSING (sizeof("auto __cdecl boost::pfr::detail::name_of_field_impl<") - 1, sizeof(">(void) noexcept") - 1, backward("->"))
  115. # elif defined(__clang__)
  116. # define BOOST_PFR_CORE_NAME_PARSING (sizeof("auto boost::pfr::detail::name_of_field_impl() [MsvcWorkaround = ") - 1, sizeof("}]") - 1, backward("."))
  117. # elif defined(__GNUC__)
  118. # define BOOST_PFR_CORE_NAME_PARSING (sizeof("consteval auto boost::pfr::detail::name_of_field_impl() [with MsvcWorkaround = ") - 1, sizeof(")]") - 1, backward("::"))
  119. # else
  120. // Default parser for other platforms... Just skip nothing!
  121. # define BOOST_PFR_CORE_NAME_PARSING (0, 0, "")
  122. # endif
  123. #endif
  124. #if defined(__has_cpp_attribute)
  125. # if __has_cpp_attribute(maybe_unused)
  126. # define BOOST_PFR_MAYBE_UNUSED [[maybe_unused]]
  127. # endif
  128. #endif
  129. #ifndef BOOST_PFR_MAYBE_UNUSED
  130. # define BOOST_PFR_MAYBE_UNUSED
  131. #endif
  132. #ifndef BOOST_PFR_ENABLED
  133. # ifdef BOOST_PFR_NOT_SUPPORTED
  134. # define BOOST_PFR_ENABLED 0
  135. # else
  136. # define BOOST_PFR_ENABLED 1
  137. # endif
  138. #endif
  139. #undef BOOST_PFR_NOT_SUPPORTED
  140. #ifdef BOOST_PFR_INTERFACE_UNIT
  141. # define BOOST_PFR_BEGIN_MODULE_EXPORT export {
  142. # define BOOST_PFR_END_MODULE_EXPORT }
  143. #else
  144. # define BOOST_PFR_BEGIN_MODULE_EXPORT
  145. # define BOOST_PFR_END_MODULE_EXPORT
  146. #endif
  147. #if defined(BOOST_USE_MODULES) && !defined(BOOST_PFR_INTERFACE_UNIT)
  148. import boost.pfr;
  149. #endif
  150. #endif // BOOST_PFR_CONFIG_HPP