1// Copyright (c) 2016-2024 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
7#ifndef BOOST_PFR_CONFIG_HPP
8#define BOOST_PFR_CONFIG_HPP
9#pragma once
10
11#if __cplusplus >= 201402L || (defined(_MSC_VER) && defined(_MSVC_LANG) && _MSC_VER > 1900)
12#include <type_traits> // to get non standard platform macro definitions (__GLIBCXX__ for example)
13#endif
14
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
20// Reminder:
21// * MSVC++ 14.2 _MSC_VER == 1927 <- Loophole is known to work (Visual Studio ????)
22// * MSVC++ 14.1 _MSC_VER == 1916 <- Loophole is known to NOT work (Visual Studio 2017)
23// * MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
24// * MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
25
26#ifdef BOOST_PFR_NOT_SUPPORTED
27# error Please, do not set BOOST_PFR_NOT_SUPPORTED value manually, use '-DBOOST_PFR_ENABLED=0' instead of it
28#endif
29
30#if defined(_MSC_VER)
31# if !defined(_MSVC_LANG) || _MSC_VER <= 1900
32# define BOOST_PFR_NOT_SUPPORTED 1
33# endif
34#elif __cplusplus < 201402L
35# define BOOST_PFR_NOT_SUPPORTED 1
36#endif
37
38#ifndef BOOST_PFR_USE_LOOPHOLE
39# if defined(_MSC_VER)
40# if _MSC_VER >= 1927
41# define BOOST_PFR_USE_LOOPHOLE 1
42# else
43# define BOOST_PFR_USE_LOOPHOLE 0
44# endif
45# elif defined(__clang_major__) && __clang_major__ >= 8
46# define BOOST_PFR_USE_LOOPHOLE 0
47# else
48# define BOOST_PFR_USE_LOOPHOLE 1
49# endif
50#endif
51
52#ifndef BOOST_PFR_USE_CPP17
53# ifdef __cpp_structured_bindings
54# define BOOST_PFR_USE_CPP17 1
55# elif defined(_MSVC_LANG)
56# if _MSVC_LANG >= 201703L
57# define BOOST_PFR_USE_CPP17 1
58# else
59# define BOOST_PFR_USE_CPP17 0
60# endif
61# else
62# define BOOST_PFR_USE_CPP17 0
63# endif
64#endif
65
66#if (!BOOST_PFR_USE_CPP17 && !BOOST_PFR_USE_LOOPHOLE)
67# if (defined(_MSC_VER) && _MSC_VER < 1916) ///< in Visual Studio 2017 v15.9 PFR library with classic engine normally works
68# define BOOST_PFR_NOT_SUPPORTED 1
69# endif
70#endif
71
72#ifndef BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE
73// Assume that libstdc++ since GCC-7.3 does not have linear instantiation depth in std::make_integral_sequence
74# if defined( __GLIBCXX__) && __GLIBCXX__ >= 20180101
75# define BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE 1
76# elif defined(_MSC_VER)
77# define BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE 1
78//# elif other known working lib
79# else
80# define BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE 0
81# endif
82#endif
83
84#ifndef BOOST_PFR_HAS_GUARANTEED_COPY_ELISION
85# if defined(__cpp_guaranteed_copy_elision) && (!defined(_MSC_VER) || _MSC_VER > 1928)
86# define BOOST_PFR_HAS_GUARANTEED_COPY_ELISION 1
87# else
88# define BOOST_PFR_HAS_GUARANTEED_COPY_ELISION 0
89# endif
90#endif
91
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
101#ifndef BOOST_PFR_CORE_NAME_ENABLED
102# if (__cplusplus >= 202002L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 202002L))
103# if (defined(__cpp_nontype_template_args) && __cpp_nontype_template_args >= 201911) \
104 || (defined(__clang_major__) && __clang_major__ >= 12)
105# define BOOST_PFR_CORE_NAME_ENABLED 1
106# else
107# define BOOST_PFR_CORE_NAME_ENABLED 0
108# endif
109# else
110# define BOOST_PFR_CORE_NAME_ENABLED 0
111# endif
112#endif
113
114
115#ifndef BOOST_PFR_CORE_NAME_PARSING
116# if defined(_MSC_VER) && !defined(__clang__)
117# define BOOST_PFR_CORE_NAME_PARSING (sizeof("auto __cdecl boost::pfr::detail::name_of_field_impl<") - 1, sizeof(">(void) noexcept") - 1, backward("->"))
118# elif defined(__clang__)
119# define BOOST_PFR_CORE_NAME_PARSING (sizeof("auto boost::pfr::detail::name_of_field_impl() [MsvcWorkaround = ") - 1, sizeof("}]") - 1, backward("."))
120# elif defined(__GNUC__)
121# define BOOST_PFR_CORE_NAME_PARSING (sizeof("consteval auto boost::pfr::detail::name_of_field_impl() [with MsvcWorkaround = ") - 1, sizeof(")]") - 1, backward("::"))
122# else
123// Default parser for other platforms... Just skip nothing!
124# define BOOST_PFR_CORE_NAME_PARSING (0, 0, "")
125# endif
126#endif
127
128#if defined(__has_cpp_attribute)
129# if __has_cpp_attribute(maybe_unused)
130# define BOOST_PFR_MAYBE_UNUSED [[maybe_unused]]
131# endif
132#endif
133
134#ifndef BOOST_PFR_MAYBE_UNUSED
135# define BOOST_PFR_MAYBE_UNUSED
136#endif
137
138#ifndef BOOST_PFR_ENABLED
139# ifdef BOOST_PFR_NOT_SUPPORTED
140# define BOOST_PFR_ENABLED 0
141# else
142# define BOOST_PFR_ENABLED 1
143# endif
144#endif
145
146#undef BOOST_PFR_NOT_SUPPORTED
147
148#endif // BOOST_PFR_CONFIG_HPP
149

source code of boost/libs/pfr/include/boost/pfr/config.hpp