100.00% Lines (4/4) 100.00% Functions (1/1)
TLA Baseline Branch
Line Hits Code Line Hits Code
1   // 1   //
2   // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) 2   // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3   // 3   //
4   // Distributed under the Boost Software License, Version 1.0. (See accompanying 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) 5   // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6   // 6   //
7   // Official repository: https://github.com/boostorg/json 7   // Official repository: https://github.com/boostorg/json
8   // 8   //
9   9  
10   #ifndef BOOST_JSON_DETAIL_CONFIG_HPP 10   #ifndef BOOST_JSON_DETAIL_CONFIG_HPP
11   #define BOOST_JSON_DETAIL_CONFIG_HPP 11   #define BOOST_JSON_DETAIL_CONFIG_HPP
12   12  
13   #include <boost/config.hpp> 13   #include <boost/config.hpp>
14   #include <boost/config/pragma_message.hpp> 14   #include <boost/config/pragma_message.hpp>
15   #include <boost/assert.hpp> 15   #include <boost/assert.hpp>
16   #include <boost/throw_exception.hpp> 16   #include <boost/throw_exception.hpp>
17   #include <cstdint> 17   #include <cstdint>
18   #include <type_traits> 18   #include <type_traits>
19   #include <utility> 19   #include <utility>
20   20  
21   // detect 32/64 bit 21   // detect 32/64 bit
22   #if UINTPTR_MAX == UINT64_MAX 22   #if UINTPTR_MAX == UINT64_MAX
23   # define BOOST_JSON_ARCH 64 23   # define BOOST_JSON_ARCH 64
24   #elif UINTPTR_MAX == UINT32_MAX 24   #elif UINTPTR_MAX == UINT32_MAX
25   # define BOOST_JSON_ARCH 32 25   # define BOOST_JSON_ARCH 32
26   #else 26   #else
27   # error Unknown or unsupported architecture, please open an issue 27   # error Unknown or unsupported architecture, please open an issue
28   #endif 28   #endif
29   29  
30   #ifndef BOOST_JSON_REQUIRE_CONST_INIT 30   #ifndef BOOST_JSON_REQUIRE_CONST_INIT
31   # define BOOST_JSON_REQUIRE_CONST_INIT 31   # define BOOST_JSON_REQUIRE_CONST_INIT
32   # if __cpp_constinit >= 201907L 32   # if __cpp_constinit >= 201907L
33   # undef BOOST_JSON_REQUIRE_CONST_INIT 33   # undef BOOST_JSON_REQUIRE_CONST_INIT
34   # define BOOST_JSON_REQUIRE_CONST_INIT constinit 34   # define BOOST_JSON_REQUIRE_CONST_INIT constinit
35   # elif defined(__clang__) && defined(__has_cpp_attribute) 35   # elif defined(__clang__) && defined(__has_cpp_attribute)
36   # if __has_cpp_attribute(clang::require_constant_initialization) 36   # if __has_cpp_attribute(clang::require_constant_initialization)
37   # undef BOOST_JSON_REQUIRE_CONST_INIT 37   # undef BOOST_JSON_REQUIRE_CONST_INIT
38   # define BOOST_JSON_REQUIRE_CONST_INIT [[clang::require_constant_initialization]] 38   # define BOOST_JSON_REQUIRE_CONST_INIT [[clang::require_constant_initialization]]
39   # endif 39   # endif
40   # endif 40   # endif
41   #endif 41   #endif
42   42  
43   #ifndef BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY 43   #ifndef BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY
44   // clang, but not clang-cl 44   // clang, but not clang-cl
45   # if defined(__clang__) && !defined(_MSC_VER) && defined(__has_cpp_attribute) 45   # if defined(__clang__) && !defined(_MSC_VER) && defined(__has_cpp_attribute)
46   # if __has_cpp_attribute(clang::no_destroy) 46   # if __has_cpp_attribute(clang::no_destroy)
47   # define BOOST_JSON_ATTRIBUTE_NO_DESTROY [[clang::no_destroy]] 47   # define BOOST_JSON_ATTRIBUTE_NO_DESTROY [[clang::no_destroy]]
48   # else 48   # else
49   # define BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY 49   # define BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY
50   # endif 50   # endif
51   # else 51   # else
52   # define BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY 52   # define BOOST_JSON_NO_ATTRIBUTE_NO_DESTROY
53   # endif 53   # endif
54   #endif 54   #endif
55   55  
56   #if ! defined(BOOST_JSON_NO_SSE2) && \ 56   #if ! defined(BOOST_JSON_NO_SSE2) && \
57   ! defined(BOOST_JSON_USE_SSE2) 57   ! defined(BOOST_JSON_USE_SSE2)
58   # if (defined(_M_IX86) && _M_IX86_FP == 2) || \ 58   # if (defined(_M_IX86) && _M_IX86_FP == 2) || \
59   defined(_M_X64) || defined(__SSE2__) 59   defined(_M_X64) || defined(__SSE2__)
60   # define BOOST_JSON_USE_SSE2 60   # define BOOST_JSON_USE_SSE2
61   # endif 61   # endif
62   #endif 62   #endif
63   63  
64   #if defined(BOOST_JSON_DOCS) 64   #if defined(BOOST_JSON_DOCS)
65   # define BOOST_JSON_DECL 65   # define BOOST_JSON_DECL
66   #else 66   #else
67   # if (defined(BOOST_JSON_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_JSON_STATIC_LINK) 67   # if (defined(BOOST_JSON_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_JSON_STATIC_LINK)
68   # if defined(BOOST_JSON_SOURCE) 68   # if defined(BOOST_JSON_SOURCE)
69   # define BOOST_JSON_DECL BOOST_SYMBOL_EXPORT 69   # define BOOST_JSON_DECL BOOST_SYMBOL_EXPORT
70   # else 70   # else
71   # define BOOST_JSON_DECL BOOST_SYMBOL_IMPORT 71   # define BOOST_JSON_DECL BOOST_SYMBOL_IMPORT
72   # endif 72   # endif
73   # endif // shared lib 73   # endif // shared lib
74   # ifndef BOOST_JSON_DECL 74   # ifndef BOOST_JSON_DECL
75   # define BOOST_JSON_DECL 75   # define BOOST_JSON_DECL
76   # endif 76   # endif
77   # if !defined(BOOST_JSON_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_JSON_NO_LIB) 77   # if !defined(BOOST_JSON_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_JSON_NO_LIB)
78   # define BOOST_LIB_NAME boost_json 78   # define BOOST_LIB_NAME boost_json
79   # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_JSON_DYN_LINK) 79   # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_JSON_DYN_LINK)
80   # define BOOST_DYN_LINK 80   # define BOOST_DYN_LINK
81   # endif 81   # endif
82   # include <boost/config/auto_link.hpp> 82   # include <boost/config/auto_link.hpp>
83   # endif 83   # endif
84   #endif 84   #endif
85   85  
86   #ifndef BOOST_JSON_LIKELY 86   #ifndef BOOST_JSON_LIKELY
87   # define BOOST_JSON_LIKELY(x) BOOST_LIKELY( !!(x) ) 87   # define BOOST_JSON_LIKELY(x) BOOST_LIKELY( !!(x) )
88   #endif 88   #endif
89   89  
90   #ifndef BOOST_JSON_UNLIKELY 90   #ifndef BOOST_JSON_UNLIKELY
91   # define BOOST_JSON_UNLIKELY(x) BOOST_UNLIKELY( !!(x) ) 91   # define BOOST_JSON_UNLIKELY(x) BOOST_UNLIKELY( !!(x) )
92   #endif 92   #endif
93   93  
94   #ifndef BOOST_JSON_UNREACHABLE 94   #ifndef BOOST_JSON_UNREACHABLE
95   # ifdef _MSC_VER 95   # ifdef _MSC_VER
96   # define BOOST_JSON_UNREACHABLE() __assume(0) 96   # define BOOST_JSON_UNREACHABLE() __assume(0)
97   # elif defined(__GNUC__) || defined(__clang__) 97   # elif defined(__GNUC__) || defined(__clang__)
98   # define BOOST_JSON_UNREACHABLE() __builtin_unreachable() 98   # define BOOST_JSON_UNREACHABLE() __builtin_unreachable()
99   # elif defined(__has_builtin) 99   # elif defined(__has_builtin)
100   # if __has_builtin(__builtin_unreachable) 100   # if __has_builtin(__builtin_unreachable)
101   # define BOOST_JSON_UNREACHABLE() __builtin_unreachable() 101   # define BOOST_JSON_UNREACHABLE() __builtin_unreachable()
102   # endif 102   # endif
103   # else 103   # else
104   # define BOOST_JSON_UNREACHABLE() static_cast<void>(0) 104   # define BOOST_JSON_UNREACHABLE() static_cast<void>(0)
105   # endif 105   # endif
106   #endif 106   #endif
107   107  
108   #ifndef BOOST_JSON_ASSUME 108   #ifndef BOOST_JSON_ASSUME
109   # define BOOST_JSON_ASSUME(x) (!!(x) ? void() : BOOST_JSON_UNREACHABLE()) 109   # define BOOST_JSON_ASSUME(x) (!!(x) ? void() : BOOST_JSON_UNREACHABLE())
110   # ifdef _MSC_VER 110   # ifdef _MSC_VER
111   # undef BOOST_JSON_ASSUME 111   # undef BOOST_JSON_ASSUME
112   # define BOOST_JSON_ASSUME(x) __assume(!!(x)) 112   # define BOOST_JSON_ASSUME(x) __assume(!!(x))
113   # elif defined(__has_builtin) 113   # elif defined(__has_builtin)
114   # if __has_builtin(__builtin_assume) 114   # if __has_builtin(__builtin_assume)
115   # undef BOOST_JSON_ASSUME 115   # undef BOOST_JSON_ASSUME
116   # define BOOST_JSON_ASSUME(x) __builtin_assume(!!(x)) 116   # define BOOST_JSON_ASSUME(x) __builtin_assume(!!(x))
117   # endif 117   # endif
118   # endif 118   # endif
119   #endif 119   #endif
120   120  
121   // older versions of msvc and clang don't always 121   // older versions of msvc and clang don't always
122   // constant initialize when they are supposed to 122   // constant initialize when they are supposed to
123   #ifndef BOOST_JSON_WEAK_CONSTINIT 123   #ifndef BOOST_JSON_WEAK_CONSTINIT
124   # if defined(_MSC_VER) && ! defined(__clang__) && _MSC_VER < 1920 124   # if defined(_MSC_VER) && ! defined(__clang__) && _MSC_VER < 1920
125   # define BOOST_JSON_WEAK_CONSTINIT 125   # define BOOST_JSON_WEAK_CONSTINIT
126   # elif defined(__clang__) && __clang_major__ < 4 126   # elif defined(__clang__) && __clang_major__ < 4
127   # define BOOST_JSON_WEAK_CONSTINIT 127   # define BOOST_JSON_WEAK_CONSTINIT
128   # endif 128   # endif
129   #endif 129   #endif
130   130  
131   // These macros are private, for tests, do not change 131   // These macros are private, for tests, do not change
132   // them or else previously built libraries won't match. 132   // them or else previously built libraries won't match.
133   #ifndef BOOST_JSON_MAX_STRING_SIZE 133   #ifndef BOOST_JSON_MAX_STRING_SIZE
134   # define BOOST_JSON_NO_MAX_STRING_SIZE 134   # define BOOST_JSON_NO_MAX_STRING_SIZE
135   # define BOOST_JSON_MAX_STRING_SIZE 0x7ffffffe 135   # define BOOST_JSON_MAX_STRING_SIZE 0x7ffffffe
136   #endif 136   #endif
137   #ifndef BOOST_JSON_MAX_STRUCTURED_SIZE 137   #ifndef BOOST_JSON_MAX_STRUCTURED_SIZE
138   # define BOOST_JSON_NO_MAX_STRUCTURED_SIZE 138   # define BOOST_JSON_NO_MAX_STRUCTURED_SIZE
139   # define BOOST_JSON_MAX_STRUCTURED_SIZE 0x7ffffffe 139   # define BOOST_JSON_MAX_STRUCTURED_SIZE 0x7ffffffe
140   #endif 140   #endif
141   #ifndef BOOST_JSON_STACK_BUFFER_SIZE 141   #ifndef BOOST_JSON_STACK_BUFFER_SIZE
142   # define BOOST_JSON_NO_STACK_BUFFER_SIZE 142   # define BOOST_JSON_NO_STACK_BUFFER_SIZE
143   # if defined(__i386__) || defined(__x86_64__) || \ 143   # if defined(__i386__) || defined(__x86_64__) || \
144   defined(_M_IX86) || defined(_M_X64) 144   defined(_M_IX86) || defined(_M_X64)
145   # define BOOST_JSON_STACK_BUFFER_SIZE 4096 145   # define BOOST_JSON_STACK_BUFFER_SIZE 4096
146   # else 146   # else
147   // If we are not on Intel, then assume we are on 147   // If we are not on Intel, then assume we are on
148   // embedded and use a smaller stack size. If this 148   // embedded and use a smaller stack size. If this
149   // is not suitable, the user can define the macro 149   // is not suitable, the user can define the macro
150   // themselves when building the library or including 150   // themselves when building the library or including
151   // src.hpp. 151   // src.hpp.
152   # define BOOST_JSON_STACK_BUFFER_SIZE 256 152   # define BOOST_JSON_STACK_BUFFER_SIZE 256
153   # endif 153   # endif
154   #endif 154   #endif
155   155  
156   #if defined(__cpp_constinit) && __cpp_constinit >= 201907L 156   #if defined(__cpp_constinit) && __cpp_constinit >= 201907L
157   # define BOOST_JSON_CONSTINIT constinit 157   # define BOOST_JSON_CONSTINIT constinit
158   #elif defined(__has_cpp_attribute) && defined(__clang__) 158   #elif defined(__has_cpp_attribute) && defined(__clang__)
159   # if __has_cpp_attribute(clang::require_constant_initialization) 159   # if __has_cpp_attribute(clang::require_constant_initialization)
160   # define BOOST_JSON_CONSTINIT [[clang::require_constant_initialization]] 160   # define BOOST_JSON_CONSTINIT [[clang::require_constant_initialization]]
161   # endif 161   # endif
162   #elif defined(__GNUC__) && (__GNUC__ >= 10) 162   #elif defined(__GNUC__) && (__GNUC__ >= 10)
163   # define BOOST_JSON_CONSTINIT __constinit 163   # define BOOST_JSON_CONSTINIT __constinit
164   #endif 164   #endif
165   #ifndef BOOST_JSON_CONSTINIT 165   #ifndef BOOST_JSON_CONSTINIT
166   # define BOOST_JSON_CONSTINIT 166   # define BOOST_JSON_CONSTINIT
167   #endif 167   #endif
168   168  
169   namespace boost { 169   namespace boost {
170   namespace json { 170   namespace json {
171   namespace detail { 171   namespace detail {
172   172  
173   template<class...> 173   template<class...>
174   struct make_void 174   struct make_void
175   { 175   {
176   using type =void; 176   using type =void;
177   }; 177   };
178   178  
179   template<class... Ts> 179   template<class... Ts>
180   using void_t = typename 180   using void_t = typename
181   make_void<Ts...>::type; 181   make_void<Ts...>::type;
182   182  
183   template<class T> 183   template<class T>
184   using remove_cvref = typename 184   using remove_cvref = typename
185   std::remove_cv<typename 185   std::remove_cv<typename
186   std::remove_reference<T>::type>::type; 186   std::remove_reference<T>::type>::type;
187   187  
188   template<class T, class U> 188   template<class T, class U>
HITCBC 189   25058786 T exchange(T& t, U u) noexcept 189   25058792 T exchange(T& t, U u) noexcept
190   { 190   {
HITCBC 191   25058786 T v = std::move(t); 191   25058792 T v = std::move(t);
HITCBC 192   25058786 t = std::move(u); 192   25058792 t = std::move(u);
HITCBC 193   25058786 return v; 193   25058792 return v;
194   } 194   }
195   195  
196   /* This is a derivative work, original copyright: 196   /* This is a derivative work, original copyright:
197   197  
198   Copyright Eric Niebler 2013-present 198   Copyright Eric Niebler 2013-present
199   199  
200   Use, modification and distribution is subject to the 200   Use, modification and distribution is subject to the
201   Boost Software License, Version 1.0. (See accompanying 201   Boost Software License, Version 1.0. (See accompanying
202   file LICENSE_1_0.txt or copy at 202   file LICENSE_1_0.txt or copy at
203   http://www.boost.org/LICENSE_1_0.txt) 203   http://www.boost.org/LICENSE_1_0.txt)
204   204  
205   Project home: https://github.com/ericniebler/range-v3 205   Project home: https://github.com/ericniebler/range-v3
206   */ 206   */
207   template<typename T> 207   template<typename T>
208   struct static_const 208   struct static_const
209   { 209   {
210   static constexpr T value {}; 210   static constexpr T value {};
211   }; 211   };
212   template<typename T> 212   template<typename T>
213   constexpr T static_const<T>::value; 213   constexpr T static_const<T>::value;
214   214  
215   #define BOOST_JSON_INLINE_VARIABLE(name, type) \ 215   #define BOOST_JSON_INLINE_VARIABLE(name, type) \
216   namespace { constexpr auto& name = \ 216   namespace { constexpr auto& name = \
217   ::boost::json::detail::static_const<type>::value; \ 217   ::boost::json::detail::static_const<type>::value; \
218   } struct _unused_ ## name ## _semicolon_bait_ 218   } struct _unused_ ## name ## _semicolon_bait_
219   219  
220   } // detail 220   } // detail
221   } // namespace json 221   } // namespace json
222   } // namespace boost 222   } // namespace boost
223   223  
224   #ifndef BOOST_JSON_ALLOW_DEPRECATED 224   #ifndef BOOST_JSON_ALLOW_DEPRECATED
225   # ifdef BOOST_ALLOW_DEPRECATED 225   # ifdef BOOST_ALLOW_DEPRECATED
226   # define BOOST_JSON_ALLOW_DEPRECATED 226   # define BOOST_JSON_ALLOW_DEPRECATED
227   # endif 227   # endif
228   #endif 228   #endif
229   229  
230   #if defined(BOOST_GCC) && BOOST_GCC < 50000 && !defined(BOOST_JSON_ALLOW_DEPRECATED) 230   #if defined(BOOST_GCC) && BOOST_GCC < 50000 && !defined(BOOST_JSON_ALLOW_DEPRECATED)
231   # pragma GCC warning "Support for GCC versions below 5.0 is deprecated and will stop in Boost 1.88.0. To suppress this message define macro BOOST_JSON_ALLOW_DEPRECATED." 231   # pragma GCC warning "Support for GCC versions below 5.0 is deprecated and will stop in Boost 1.88.0. To suppress this message define macro BOOST_JSON_ALLOW_DEPRECATED."
232   #endif 232   #endif
233   233  
234   #ifndef BOOST_JSON_ALLOW_DEPRECATED 234   #ifndef BOOST_JSON_ALLOW_DEPRECATED
235   # define BOOST_JSON_DEPRECATED(x) BOOST_DEPRECATED(x) 235   # define BOOST_JSON_DEPRECATED(x) BOOST_DEPRECATED(x)
236   #else 236   #else
237   # define BOOST_JSON_DEPRECATED(x) 237   # define BOOST_JSON_DEPRECATED(x)
238   #endif 238   #endif
239   239  
240   #ifndef BOOST_ALL_NO_EMBEDDED_GDB_SCRIPTS 240   #ifndef BOOST_ALL_NO_EMBEDDED_GDB_SCRIPTS
241   #include <boost/json/detail/gdb_printers.hpp> 241   #include <boost/json/detail/gdb_printers.hpp>
242   #endif 242   #endif
243   243  
244   #endif 244   #endif