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