Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
preprocessor.hpp
Go to the documentation of this file.
1// # This file is a part of toml++ and is subject to the the terms of the MIT license.
2// # Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
3// # See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
4// SPDX-License-Identifier: MIT
5#pragma once
6
7// #=====================================================================================================================
8// # C++ VERSION
9// #=====================================================================================================================
10
11#ifndef __cplusplus
12#error toml++ is a C++ library.
13#endif
14
15#ifndef TOML_CPP
16#ifdef _MSVC_LANG
17#if _MSVC_LANG > __cplusplus
18#define TOML_CPP _MSVC_LANG
19#endif
20#endif
21#ifndef TOML_CPP
22#define TOML_CPP __cplusplus
23#endif
24#if TOML_CPP >= 202900L
25#undef TOML_CPP
26#define TOML_CPP 29
27#elif TOML_CPP >= 202600L
28#undef TOML_CPP
29#define TOML_CPP 26
30#elif TOML_CPP >= 202302L
31#undef TOML_CPP
32#define TOML_CPP 23
33#elif TOML_CPP >= 202002L
34#undef TOML_CPP
35#define TOML_CPP 20
36#elif TOML_CPP >= 201703L
37#undef TOML_CPP
38#define TOML_CPP 17
39#elif TOML_CPP >= 201402L
40#undef TOML_CPP
41#define TOML_CPP 14
42#elif TOML_CPP >= 201103L
43#undef TOML_CPP
44#define TOML_CPP 11
45#else
46#undef TOML_CPP
47#define TOML_CPP 0
48#endif
49#endif
50
51#if !TOML_CPP
52#error toml++ requires C++17 or higher. For a pre-C++11 TOML library see https://github.com/ToruNiina/Boost.toml
53#elif TOML_CPP < 17
54#error toml++ requires C++17 or higher. For a C++11 TOML library see https://github.com/ToruNiina/toml11
55#endif
56
57// #=====================================================================================================================
58// # COMPILER
59// #=====================================================================================================================
60
61#ifndef TOML_MAKE_VERSION
62#define TOML_MAKE_VERSION(major, minor, patch) (((major) * 10000) + ((minor) * 100) + ((patch)))
63#endif
64
65#ifndef TOML_INTELLISENSE
66#ifdef __INTELLISENSE__
67#define TOML_INTELLISENSE 1
68#else
69#define TOML_INTELLISENSE 0
70#endif
71#endif
72
73#ifndef TOML_DOXYGEN
74#if defined(DOXYGEN) || defined(__DOXYGEN) || defined(__DOXYGEN__) || defined(__doxygen__) || \
75 defined(__POXY__) || defined(__poxy__)
76#define TOML_DOXYGEN 1
77#else
78#define TOML_DOXYGEN 0
79#endif
80#endif
81
82#ifndef TOML_CLANG
83#ifdef __clang__
84#define TOML_CLANG __clang_major__
85#else
86#define TOML_CLANG 0
87#endif
88
89// special handling for apple clang; see:
90// - https://github.com/marzer/tomlplusplus/issues/189
91// - https://en.wikipedia.org/wiki/Xcode
92// -
93// https://stackoverflow.com/questions/19387043/how-can-i-reliably-detect-the-version-of-clang-at-preprocessing-time
94#if TOML_CLANG && defined(__apple_build_version__)
95#undef TOML_CLANG
96#define TOML_CLANG_VERSION TOML_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
97#if TOML_CLANG_VERSION >= TOML_MAKE_VERSION(15, 0, 0)
98#define TOML_CLANG 16
99#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(14, 3, 0)
100#define TOML_CLANG 15
101#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(14, 0, 0)
102#define TOML_CLANG 14
103#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(13, 1, 6)
104#define TOML_CLANG 13
105#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(13, 0, 0)
106#define TOML_CLANG 12
107#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(12, 0, 5)
108#define TOML_CLANG 11
109#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(12, 0, 0)
110#define TOML_CLANG 10
111#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(11, 0, 3)
112#define TOML_CLANG 9
113#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(11, 0, 0)
114#define TOML_CLANG 8
115#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(10, 0, 1)
116#define TOML_CLANG 7
117#else
118#define TOML_CLANG 6 // not strictly correct but doesn't matter below this
119#endif
120#undef TOML_CLANG_VERSION
121#endif
122#endif
123
124#ifndef TOML_ICC
125#ifdef __INTEL_COMPILER
126#define TOML_ICC __INTEL_COMPILER
127#ifdef __ICL
128#define TOML_ICC_CL TOML_ICC
129#else
130#define TOML_ICC_CL 0
131#endif
132#else
133#define TOML_ICC 0
134#define TOML_ICC_CL 0
135#endif
136#endif
137
138#ifndef TOML_MSVC_LIKE
139#ifdef _MSC_VER
140#define TOML_MSVC_LIKE _MSC_VER
141#else
142#define TOML_MSVC_LIKE 0
143#endif
144#endif
145
146#ifndef TOML_MSVC
147#if TOML_MSVC_LIKE && !TOML_CLANG && !TOML_ICC
148#define TOML_MSVC TOML_MSVC_LIKE
149#else
150#define TOML_MSVC 0
151#endif
152#endif
153
154#ifndef TOML_GCC_LIKE
155#ifdef __GNUC__
156#define TOML_GCC_LIKE __GNUC__
157#else
158#define TOML_GCC_LIKE 0
159#endif
160#endif
161
162#ifndef TOML_GCC
163#if TOML_GCC_LIKE && !TOML_CLANG && !TOML_ICC
164#define TOML_GCC TOML_GCC_LIKE
165#else
166#define TOML_GCC 0
167#endif
168#endif
169
170#ifndef TOML_CUDA
171#if defined(__CUDACC__) || defined(__CUDA_ARCH__) || defined(__CUDA_LIBDEVICE__)
172#define TOML_CUDA 1
173#else
174#define TOML_CUDA 0
175#endif
176#endif
177
178// #=====================================================================================================================
179// # ARCHITECTURE
180// #=====================================================================================================================
181
182#ifndef TOML_ARCH_ITANIUM
183#if defined(__ia64__) || defined(__ia64) || defined(_IA64) || defined(__IA64__) || defined(_M_IA64)
184#define TOML_ARCH_ITANIUM 1
185#define TOML_ARCH_BITNESS 64
186#else
187#define TOML_ARCH_ITANIUM 0
188#endif
189#endif
190
191#ifndef TOML_ARCH_AMD64
192#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || \
193 defined(_M_AMD64)
194#define TOML_ARCH_AMD64 1
195#define TOML_ARCH_BITNESS 64
196#else
197#define TOML_ARCH_AMD64 0
198#endif
199#endif
200
201#ifndef TOML_ARCH_X86
202#if defined(__i386__) || defined(_M_IX86)
203#define TOML_ARCH_X86 1
204#define TOML_ARCH_BITNESS 32
205#else
206#define TOML_ARCH_X86 0
207#endif
208#endif
209
210#ifndef TOML_ARCH_ARM
211#if defined(__aarch64__) || defined(__ARM_ARCH_ISA_A64) || defined(_M_ARM64) || \
212 defined(__ARM_64BIT_STATE) || defined(_M_ARM64EC)
213#define TOML_ARCH_ARM32 0
214#define TOML_ARCH_ARM64 1
215#define TOML_ARCH_ARM 1
216#define TOML_ARCH_BITNESS 64
217#elif defined(__arm__) || defined(_M_ARM) || defined(__ARM_32BIT_STATE)
218#define TOML_ARCH_ARM32 1
219#define TOML_ARCH_ARM64 0
220#define TOML_ARCH_ARM 1
221#define TOML_ARCH_BITNESS 32
222#else
223#define TOML_ARCH_ARM32 0
224#define TOML_ARCH_ARM64 0
225#define TOML_ARCH_ARM 0
226#endif
227#endif
228
229#ifndef TOML_ARCH_BITNESS
230#define TOML_ARCH_BITNESS 0
231#endif
232
233#ifndef TOML_ARCH_X64
234#if TOML_ARCH_BITNESS == 64
235#define TOML_ARCH_X64 1
236#else
237#define TOML_ARCH_X64 0
238#endif
239#endif
240
241// #=====================================================================================================================
242// # OS
243// #=====================================================================================================================
244
245#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || \
246 defined(__CYGWIN__)
247#define TOML_WINDOWS 1
248#else
249#define TOML_WINDOWS 0
250#endif
251
252#ifdef __unix__
253#define TOML_UNIX 1
254#else
255#define TOML_UNIX 0
256#endif
257
258#ifdef __linux__
259#define TOML_LINUX 1
260#else
261#define TOML_LINUX 0
262#endif
263
264// #=====================================================================================================================
265// # ATTRIBUTES / FEATURE DETECTION / UTILITY MACROS
266// #=====================================================================================================================
267
268// TOML_HAS_INCLUDE
269#ifndef TOML_HAS_INCLUDE
270#ifdef __has_include
271#define TOML_HAS_INCLUDE(header) __has_include(header)
272#else
273#define TOML_HAS_INCLUDE(header) 0
274#endif
275#endif
276
277// TOML_HAS_BUILTIN
278#ifndef TOML_HAS_BUILTIN
279#ifdef __has_builtin
280#define TOML_HAS_BUILTIN(name) __has_builtin(name)
281#else
282#define TOML_HAS_BUILTIN(name) 0
283#endif
284#endif
285
286// TOML_HAS_FEATURE
287#ifndef TOML_HAS_FEATURE
288#ifdef __has_feature
289#define TOML_HAS_FEATURE(name) __has_feature(name)
290#else
291#define TOML_HAS_FEATURE(name) 0
292#endif
293#endif
294
295// TOML_HAS_ATTR
296#ifndef TOML_HAS_ATTR
297#ifdef __has_attribute
298#define TOML_HAS_ATTR(attr) __has_attribute(attr)
299#else
300#define TOML_HAS_ATTR(attr) 0
301#endif
302#endif
303
304// TOML_HAS_CPP_ATTR
305#ifndef TOML_HAS_CPP_ATTR
306#ifdef __has_cpp_attribute
307#define TOML_HAS_CPP_ATTR(attr) __has_cpp_attribute(attr)
308#else
309#define TOML_HAS_CPP_ATTR(attr) 0
310#endif
311#endif
312
313// TOML_ATTR (gnu attributes)
314#ifndef TOML_ATTR
315#if TOML_CLANG || TOML_GCC_LIKE
316#define TOML_ATTR(...) __attribute__((__VA_ARGS__))
317#else
318#define TOML_ATTR(...)
319#endif
320#endif
321
322// TOML_DECLSPEC (msvc attributes)
323#ifndef TOML_DECLSPEC
324#if TOML_MSVC_LIKE
325#define TOML_DECLSPEC(...) __declspec(__VA_ARGS__)
326#else
327#define TOML_DECLSPEC(...)
328#endif
329#endif
330
331// TOML_COMPILER_HAS_EXCEPTIONS
332#ifndef TOML_COMPILER_HAS_EXCEPTIONS
333#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) || defined(__cpp_exceptions)
334#define TOML_COMPILER_HAS_EXCEPTIONS 1
335#else
336#define TOML_COMPILER_HAS_EXCEPTIONS 0
337#endif
338#endif
339
340// TOML_COMPILER_HAS_RTTI
341#ifndef TOML_COMPILER_HAS_RTTI
342#if defined(_CPPRTTI) || defined(__GXX_RTTI) || TOML_HAS_FEATURE(cxx_rtti)
343#define TOML_COMPILER_HAS_RTTI 1
344#else
345#define TOML_COMPILER_HAS_RTTI 0
346#endif
347#endif
348
349// TOML_CONCAT
350#define TOML_CONCAT_1(x, y) x##y
351#define TOML_CONCAT(x, y) TOML_CONCAT_1(x, y)
352
353// TOML_MAKE_STRING
354#define TOML_MAKE_STRING_1(s) #s
355#define TOML_MAKE_STRING(s) TOML_MAKE_STRING_1(s)
356
357// TOML_PRAGMA_XXXX (compiler-specific pragmas)
358#if TOML_CLANG
359#define TOML_PRAGMA_CLANG(decl) _Pragma(TOML_MAKE_STRING(clang decl))
360#else
361#define TOML_PRAGMA_CLANG(decl)
362#endif
363#if TOML_CLANG >= 8
364#define TOML_PRAGMA_CLANG_GE_8(decl) TOML_PRAGMA_CLANG(decl)
365#else
366#define TOML_PRAGMA_CLANG_GE_8(decl)
367#endif
368#if TOML_CLANG >= 9
369#define TOML_PRAGMA_CLANG_GE_9(decl) TOML_PRAGMA_CLANG(decl)
370#else
371#define TOML_PRAGMA_CLANG_GE_9(decl)
372#endif
373#if TOML_CLANG >= 10
374#define TOML_PRAGMA_CLANG_GE_10(decl) TOML_PRAGMA_CLANG(decl)
375#else
376#define TOML_PRAGMA_CLANG_GE_10(decl)
377#endif
378#if TOML_CLANG >= 11
379#define TOML_PRAGMA_CLANG_GE_11(decl) TOML_PRAGMA_CLANG(decl)
380#else
381#define TOML_PRAGMA_CLANG_GE_11(decl)
382#endif
383#if TOML_GCC
384#define TOML_PRAGMA_GCC(decl) _Pragma(TOML_MAKE_STRING(GCC decl))
385#else
386#define TOML_PRAGMA_GCC(decl)
387#endif
388#if TOML_MSVC
389#define TOML_PRAGMA_MSVC(...) __pragma(__VA_ARGS__)
390#else
391#define TOML_PRAGMA_MSVC(...)
392#endif
393#if TOML_ICC
394#define TOML_PRAGMA_ICC(...) __pragma(__VA_ARGS__)
395#else
396#define TOML_PRAGMA_ICC(...)
397#endif
398
399// TOML_ALWAYS_INLINE
400#ifdef _MSC_VER
401#define TOML_ALWAYS_INLINE __forceinline
402#elif TOML_GCC || TOML_CLANG || TOML_HAS_ATTR(__always_inline__)
403#define TOML_ALWAYS_INLINE \
404 TOML_ATTR(__always_inline__) \
405 inline
406#else
407#define TOML_ALWAYS_INLINE inline
408#endif
409
410// TOML_NEVER_INLINE
411#ifdef _MSC_VER
412#define TOML_NEVER_INLINE TOML_DECLSPEC(noinline)
413#elif TOML_CUDA // https://gitlab.gnome.org/GNOME/glib/-/issues/2555
414#define TOML_NEVER_INLINE TOML_ATTR(noinline)
415#else
416#if TOML_GCC || TOML_CLANG || TOML_HAS_ATTR(__noinline__)
417#define TOML_NEVER_INLINE TOML_ATTR(__noinline__)
418#endif
419#endif
420#ifndef TOML_NEVER_INLINE
421#define TOML_NEVER_INLINE
422#endif
423
424// MSVC attributes
425#define TOML_ABSTRACT_INTERFACE TOML_DECLSPEC(novtable)
426#define TOML_EMPTY_BASES TOML_DECLSPEC(empty_bases)
427
428// TOML_TRIVIAL_ABI
429#if TOML_CLANG || TOML_HAS_ATTR(__trivial_abi__)
430#define TOML_TRIVIAL_ABI TOML_ATTR(__trivial_abi__)
431#else
432#define TOML_TRIVIAL_ABI
433#endif
434
435// TOML_NODISCARD
436#if TOML_CPP >= 17 && TOML_HAS_CPP_ATTR(nodiscard) >= 201603
437#define TOML_NODISCARD [[nodiscard]]
438#elif TOML_CLANG || TOML_GCC || TOML_HAS_ATTR(__warn_unused_result__)
439#define TOML_NODISCARD TOML_ATTR(__warn_unused_result__)
440#else
441#define TOML_NODISCARD
442#endif
443
444// TOML_NODISCARD_CTOR
445#if TOML_CPP >= 17 && TOML_HAS_CPP_ATTR(nodiscard) >= 201907
446#define TOML_NODISCARD_CTOR [[nodiscard]]
447#else
448#define TOML_NODISCARD_CTOR
449#endif
450
451// pure + const
452#ifndef TOML_PURE
453#ifdef NDEBUG
454#define TOML_PURE \
455 TOML_DECLSPEC(noalias) \
456 TOML_ATTR(pure)
457#else
458#define TOML_PURE
459#endif
460#endif
461#ifndef TOML_CONST
462#ifdef NDEBUG
463#define TOML_CONST \
464 TOML_DECLSPEC(noalias) \
465 TOML_ATTR(const)
466#else
467#define TOML_CONST
468#endif
469#endif
470#ifndef TOML_INLINE_GETTER
471#define TOML_INLINE_GETTER \
472 TOML_NODISCARD \
473 TOML_ALWAYS_INLINE
474#endif
475#ifndef TOML_PURE_GETTER
476#define TOML_PURE_GETTER \
477 TOML_NODISCARD \
478 TOML_PURE
479#endif
480#ifndef TOML_PURE_INLINE_GETTER
481#define TOML_PURE_INLINE_GETTER \
482 TOML_NODISCARD \
483 TOML_ALWAYS_INLINE \
484 TOML_PURE
485#endif
486#ifndef TOML_CONST_GETTER
487#define TOML_CONST_GETTER \
488 TOML_NODISCARD \
489 TOML_CONST
490#endif
491#ifndef TOML_CONST_INLINE_GETTER
492#define TOML_CONST_INLINE_GETTER \
493 TOML_NODISCARD \
494 TOML_ALWAYS_INLINE \
495 TOML_CONST
496#endif
497
498// TOML_ASSUME
499#ifdef _MSC_VER
500#define TOML_ASSUME(expr) __assume(expr)
501#elif TOML_ICC || TOML_CLANG || TOML_HAS_BUILTIN(__builtin_assume)
502#define TOML_ASSUME(expr) __builtin_assume(expr)
503#elif TOML_HAS_CPP_ATTR(assume) >= 202207
504#define TOML_ASSUME(expr) [[assume(expr)]]
505#elif TOML_HAS_ATTR(__assume__)
506#define TOML_ASSUME(expr) __attribute__((__assume__(expr)))
507#else
508#define TOML_ASSUME(expr) static_cast<void>(0)
509#endif
510
511// TOML_UNREACHABLE
512#ifdef _MSC_VER
513#define TOML_UNREACHABLE __assume(0)
514#elif TOML_ICC || TOML_CLANG || TOML_GCC || TOML_HAS_BUILTIN(__builtin_unreachable)
515#define TOML_UNREACHABLE __builtin_unreachable()
516#else
517#define TOML_UNREACHABLE static_cast<void>(0)
518#endif
519
520// TOML_LIKELY
521#if TOML_CPP >= 20 && TOML_HAS_CPP_ATTR(likely) >= 201803
522#define TOML_LIKELY(...) (__VA_ARGS__) [[likely]]
523#define TOML_LIKELY_CASE [[likely]]
524#elif TOML_GCC || TOML_CLANG || TOML_HAS_BUILTIN(__builtin_expect)
525#define TOML_LIKELY(...) (__builtin_expect(!!(__VA_ARGS__), 1))
526#else
527#define TOML_LIKELY(...) (__VA_ARGS__)
528#endif
529#ifndef TOML_LIKELY_CASE
530#define TOML_LIKELY_CASE
531#endif
532
533// TOML_UNLIKELY
534#if TOML_CPP >= 20 && TOML_HAS_CPP_ATTR(unlikely) >= 201803
535#define TOML_UNLIKELY(...) (__VA_ARGS__) [[unlikely]]
536#define TOML_UNLIKELY_CASE [[unlikely]]
537#elif TOML_GCC || TOML_CLANG || TOML_HAS_BUILTIN(__builtin_expect)
538#define TOML_UNLIKELY(...) (__builtin_expect(!!(__VA_ARGS__), 0))
539#else
540#define TOML_UNLIKELY(...) (__VA_ARGS__)
541#endif
542#ifndef TOML_UNLIKELY_CASE
543#define TOML_UNLIKELY_CASE
544#endif
545
546// TOML_FLAGS_ENUM
547#if TOML_CLANG || TOML_HAS_ATTR(flag_enum)
548#define TOML_FLAGS_ENUM __attribute__((flag_enum))
549#else
550#define TOML_FLAGS_ENUM
551#endif
552
553// TOML_OPEN_ENUM + TOML_CLOSED_ENUM
554#if TOML_CLANG || TOML_HAS_ATTR(enum_extensibility)
555#define TOML_OPEN_ENUM __attribute__((enum_extensibility(open)))
556#define TOML_CLOSED_ENUM __attribute__((enum_extensibility(closed)))
557#else
558#define TOML_OPEN_ENUM
559#define TOML_CLOSED_ENUM
560#endif
561
562// TOML_OPEN_FLAGS_ENUM + TOML_CLOSED_FLAGS_ENUM
563#define TOML_OPEN_FLAGS_ENUM TOML_OPEN_ENUM TOML_FLAGS_ENUM
564#define TOML_CLOSED_FLAGS_ENUM TOML_CLOSED_ENUM TOML_FLAGS_ENUM
565
566// TOML_MAKE_FLAGS
567#define TOML_MAKE_FLAGS_2(T, op, linkage) \
568 TOML_CONST_INLINE_GETTER \
569 linkage constexpr T operator op(T lhs, T rhs) noexcept { \
570 using under = std::underlying_type_t<T>; \
571 return static_cast<T>(static_cast<under>(lhs) op static_cast<under>(rhs)); \
572 } \
573 \
574 linkage constexpr T& operator TOML_CONCAT(op, =)(T & lhs, T rhs) noexcept { \
575 return lhs = (lhs op rhs); \
576 } \
577 \
578 static_assert(true)
579#define TOML_MAKE_FLAGS_1(T, linkage) \
580 static_assert(std::is_enum_v<T>); \
581 \
582 TOML_MAKE_FLAGS_2(T, &, linkage); \
583 TOML_MAKE_FLAGS_2(T, |, linkage); \
584 TOML_MAKE_FLAGS_2(T, ^, linkage); \
585 \
586 TOML_CONST_INLINE_GETTER \
587 linkage constexpr T operator~(T val) noexcept { \
588 using under = std::underlying_type_t<T>; \
589 return static_cast<T>(~static_cast<under>(val)); \
590 } \
591 \
592 TOML_CONST_INLINE_GETTER \
593 linkage constexpr bool operator!(T val) noexcept { \
594 using under = std::underlying_type_t<T>; \
595 return !static_cast<under>(val); \
596 } \
597 \
598 static_assert(true)
599#define TOML_MAKE_FLAGS(T) TOML_MAKE_FLAGS_1(T, )
600
601#define TOML_UNUSED(...) static_cast<void>(__VA_ARGS__)
602
603#define TOML_DELETE_DEFAULTS(T) \
604 T(const T&) = delete; \
605 T(T&&) = delete; \
606 T& operator=(const T&) = delete; \
607 T& operator=(T&&) = delete
608
609#define TOML_ASYMMETRICAL_EQUALITY_OPS(LHS, RHS, ...) \
610 __VA_ARGS__ TOML_NODISCARD friend bool operator==(RHS rhs, LHS lhs) noexcept { \
611 return lhs == rhs; \
612 } \
613 __VA_ARGS__ TOML_NODISCARD friend bool operator!=(LHS lhs, RHS rhs) noexcept { \
614 return !(lhs == rhs); \
615 } \
616 __VA_ARGS__ TOML_NODISCARD friend bool operator!=(RHS rhs, LHS lhs) noexcept { \
617 return !(lhs == rhs); \
618 } \
619 static_assert(true)
620
621#define TOML_EVAL_BOOL_1(T, F) T
622#define TOML_EVAL_BOOL_0(T, F) F
623
624#if !defined(__POXY__) && !defined(POXY_IMPLEMENTATION_DETAIL)
625#define POXY_IMPLEMENTATION_DETAIL(...) __VA_ARGS__
626#endif
627
628//======================================================================================================================
629// COMPILER-SPECIFIC WARNING MANAGEMENT
630//======================================================================================================================
631
632#if TOML_CLANG
633
634#define TOML_PUSH_WARNINGS \
635 TOML_PRAGMA_CLANG(diagnostic push) \
636 TOML_PRAGMA_CLANG(diagnostic ignored "-Wunknown-warning-option") \
637 static_assert(true)
638
639#define TOML_DISABLE_SWITCH_WARNINGS \
640 TOML_PRAGMA_CLANG(diagnostic ignored "-Wswitch") \
641 static_assert(true)
642
643#define TOML_DISABLE_ARITHMETIC_WARNINGS \
644 TOML_PRAGMA_CLANG_GE_10(diagnostic ignored "-Wimplicit-int-float-conversion") \
645 TOML_PRAGMA_CLANG(diagnostic ignored "-Wfloat-equal") \
646 TOML_PRAGMA_CLANG(diagnostic ignored "-Wdouble-promotion") \
647 TOML_PRAGMA_CLANG(diagnostic ignored "-Wchar-subscripts") \
648 TOML_PRAGMA_CLANG(diagnostic ignored "-Wshift-sign-overflow") \
649 static_assert(true)
650
651#define TOML_DISABLE_SPAM_WARNINGS \
652 TOML_PRAGMA_CLANG_GE_8(diagnostic ignored "-Wdefaulted-function-deleted") \
653 TOML_PRAGMA_CLANG_GE_9(diagnostic ignored "-Wctad-maybe-unsupported") \
654 TOML_PRAGMA_CLANG_GE_10(diagnostic ignored "-Wzero-as-null-pointer-constant") \
655 TOML_PRAGMA_CLANG_GE_11(diagnostic ignored "-Wsuggest-destructor-override") \
656 TOML_PRAGMA_CLANG(diagnostic ignored "-Wweak-vtables") \
657 TOML_PRAGMA_CLANG(diagnostic ignored "-Wweak-template-vtables") \
658 TOML_PRAGMA_CLANG(diagnostic ignored "-Wdouble-promotion") \
659 TOML_PRAGMA_CLANG(diagnostic ignored "-Wchar-subscripts") \
660 TOML_PRAGMA_CLANG(diagnostic ignored "-Wmissing-field-initializers") \
661 TOML_PRAGMA_CLANG(diagnostic ignored "-Wpadded") \
662 static_assert(true)
663
664#define TOML_POP_WARNINGS \
665 TOML_PRAGMA_CLANG(diagnostic pop) \
666 static_assert(true)
667
668#define TOML_DISABLE_WARNINGS \
669 TOML_PRAGMA_CLANG(diagnostic push) \
670 TOML_PRAGMA_CLANG(diagnostic ignored "-Weverything") \
671 static_assert(true, "")
672
673#define TOML_ENABLE_WARNINGS \
674 TOML_PRAGMA_CLANG(diagnostic pop) \
675 static_assert(true)
676
677#define TOML_SIMPLE_STATIC_ASSERT_MESSAGES 1
678
679#elif TOML_MSVC
680
681#define TOML_PUSH_WARNINGS __pragma(warning(push)) static_assert(true)
682
683#if TOML_HAS_INCLUDE(<CodeAnalysis / Warnings.h>)
684#pragma warning(push, 0)
685#include <CodeAnalysis/Warnings.h>
686#pragma warning(pop)
687#define TOML_DISABLE_CODE_ANALYSIS_WARNINGS \
688 __pragma(warning(disable : ALL_CODE_ANALYSIS_WARNINGS)) static_assert(true)
689#else
690#define TOML_DISABLE_CODE_ANALYSIS_WARNINGS static_assert(true)
691#endif
692
693#define TOML_DISABLE_SWITCH_WARNINGS \
694 __pragma(warning(disable : 4061)) __pragma(warning(disable : 4062)) \
695 __pragma(warning(disable : 4063)) __pragma( \
696 warning(disable : 5262)) /* switch-case implicit fallthrough (false-positive) */ \
697 __pragma(warning(disable : 26819)) /* cg: unannotated fallthrough */ \
698 static_assert(true)
699
700#define TOML_DISABLE_SPAM_WARNINGS \
701 __pragma(warning(disable : 4127)) /* conditional expr is constant */ \
702 __pragma(warning(disable : 4324)) /* structure was padded due to alignment specifier */ \
703 __pragma(warning(disable : 4348)) \
704 __pragma(warning(disable : 4464)) /* relative include path contains '..' */ \
705 __pragma(warning(disable : 4505)) /* unreferenced local function removed */ \
706 __pragma(warning(disable : 4514)) /* unreferenced inline function has been removed */ \
707 __pragma(warning(disable : 4582)) /* constructor is not implicitly called */ \
708 __pragma(warning(disable : 4619)) /* there is no warning number 'XXXX' */ \
709 __pragma( \
710 warning(disable : 4623)) /* default constructor was implicitly defined as deleted */ \
711 __pragma(warning(disable : 4625)) /* copy constructor was implicitly defined as deleted */ \
712 __pragma( \
713 warning(disable : 4626)) /* assignment operator was implicitly defined as deleted */ \
714 __pragma(warning(disable : 4710)) /* function not inlined */ \
715 __pragma(warning(disable : 4711)) /* function selected for automatic expansion */ \
716 __pragma(warning(disable : 4820)) /* N bytes padding added */ \
717 __pragma(warning(disable : 4946)) /* reinterpret_cast used between related classes */ \
718 __pragma(warning(disable : 5026)) /* move constructor was implicitly defined as deleted */ \
719 __pragma(warning( \
720 disable : 5027)) /* move assignment operator was implicitly defined as deleted */ \
721 __pragma(warning( \
722 disable : 5039)) /* potentially throwing function passed to 'extern "C"' function */ \
723 __pragma(warning(disable : 5045)) /* Compiler will insert Spectre mitigation */ \
724 __pragma(warning(disable : 5264)) /* const variable is not used (false-positive) */ \
725 __pragma(warning(disable : 26451)) __pragma(warning(disable : 26490)) \
726 __pragma(warning(disable : 26495)) __pragma(warning(disable : 26812)) \
727 __pragma(warning(disable : 26819)) static_assert(true)
728
729#define TOML_DISABLE_ARITHMETIC_WARNINGS \
730 __pragma(warning(disable : 4365)) /* argument signed/unsigned mismatch */ \
731 __pragma(warning(disable : 4738)) /* storing 32-bit float result in memory */ \
732 __pragma(warning(disable : 5219)) /* implicit conversion from integral to float */ \
733 static_assert(true)
734
735#define TOML_POP_WARNINGS __pragma(warning(pop)) static_assert(true)
736
737#define TOML_DISABLE_WARNINGS \
738 __pragma(warning(push, 0)) __pragma(warning(disable : 4348)) __pragma(warning(disable : 4668)) \
739 __pragma(warning(disable : 5105)) __pragma(warning(disable : 5264)) \
740 TOML_DISABLE_CODE_ANALYSIS_WARNINGS; \
741 TOML_DISABLE_SWITCH_WARNINGS; \
742 TOML_DISABLE_SPAM_WARNINGS; \
743 TOML_DISABLE_ARITHMETIC_WARNINGS; \
744 static_assert(true)
745
746#define TOML_ENABLE_WARNINGS TOML_POP_WARNINGS
747
748#elif TOML_ICC
749
750#define TOML_PUSH_WARNINGS __pragma(warning(push)) static_assert(true)
751
752#define TOML_DISABLE_SPAM_WARNINGS \
753 __pragma(warning(disable : 82)) /* storage class is not first */ \
754 __pragma(warning(disable : 111)) /* statement unreachable (false-positive) */ \
755 __pragma(warning(disable : 869)) /* unreferenced parameter */ \
756 __pragma(warning(disable : 1011)) /* missing return (false-positive) */ \
757 __pragma(warning(disable : 2261)) /* assume expr side-effects discarded */ \
758 static_assert(true)
759
760#define TOML_POP_WARNINGS __pragma(warning(pop)) static_assert(true)
761
762#define TOML_DISABLE_WARNINGS __pragma(warning(push, 0)) TOML_DISABLE_SPAM_WARNINGS
763
764#define TOML_ENABLE_WARNINGS __pragma(warning(pop)) static_assert(true)
765
766#elif TOML_GCC
767
768#define TOML_PUSH_WARNINGS \
769 TOML_PRAGMA_GCC(diagnostic push) \
770 static_assert(true)
771
772#define TOML_DISABLE_SWITCH_WARNINGS \
773 TOML_PRAGMA_GCC(diagnostic ignored "-Wswitch") \
774 TOML_PRAGMA_GCC(diagnostic ignored "-Wswitch-enum") \
775 TOML_PRAGMA_GCC(diagnostic ignored "-Wswitch-default") \
776 static_assert(true)
777
778#define TOML_DISABLE_ARITHMETIC_WARNINGS \
779 TOML_PRAGMA_GCC(diagnostic ignored "-Wfloat-equal") \
780 TOML_PRAGMA_GCC(diagnostic ignored "-Wsign-conversion") \
781 TOML_PRAGMA_GCC(diagnostic ignored "-Wchar-subscripts") \
782 static_assert(true)
783
784#define TOML_DISABLE_SUGGEST_ATTR_WARNINGS \
785 TOML_PRAGMA_GCC(diagnostic ignored "-Wsuggest-attribute=const") \
786 TOML_PRAGMA_GCC(diagnostic ignored "-Wsuggest-attribute=pure") \
787 static_assert(true)
788
789#define TOML_DISABLE_SPAM_WARNINGS \
790 TOML_PRAGMA_GCC(diagnostic ignored "-Wpadded") \
791 TOML_PRAGMA_GCC(diagnostic ignored "-Wcast-align") \
792 TOML_PRAGMA_GCC(diagnostic ignored "-Wcomment") \
793 TOML_PRAGMA_GCC(diagnostic ignored "-Wtype-limits") \
794 TOML_PRAGMA_GCC(diagnostic ignored "-Wuseless-cast") \
795 TOML_PRAGMA_GCC(diagnostic ignored "-Wchar-subscripts") \
796 TOML_PRAGMA_GCC(diagnostic ignored "-Wsubobject-linkage") \
797 TOML_PRAGMA_GCC(diagnostic ignored "-Wmissing-field-initializers") \
798 TOML_PRAGMA_GCC(diagnostic ignored "-Wmaybe-uninitialized") \
799 TOML_PRAGMA_GCC(diagnostic ignored "-Wnoexcept") \
800 TOML_PRAGMA_GCC(diagnostic ignored "-Wnull-dereference") \
801 TOML_PRAGMA_GCC(diagnostic ignored "-Wduplicated-branches") \
802 static_assert(true)
803
804#define TOML_POP_WARNINGS \
805 TOML_PRAGMA_GCC(diagnostic pop) \
806 static_assert(true)
807
808#define TOML_DISABLE_WARNINGS \
809 TOML_PRAGMA_GCC(diagnostic push) \
810 TOML_PRAGMA_GCC(diagnostic ignored "-Wall") \
811 TOML_PRAGMA_GCC(diagnostic ignored "-Wextra") \
812 TOML_PRAGMA_GCC(diagnostic ignored "-Wpedantic") \
813 TOML_DISABLE_SWITCH_WARNINGS; \
814 TOML_DISABLE_ARITHMETIC_WARNINGS; \
815 TOML_DISABLE_SUGGEST_ATTR_WARNINGS; \
816 TOML_DISABLE_SPAM_WARNINGS; \
817 static_assert(true)
818
819#define TOML_ENABLE_WARNINGS \
820 TOML_PRAGMA_GCC(diagnostic pop) \
821 static_assert(true)
822
823#endif
824
825#ifndef TOML_PUSH_WARNINGS
826#define TOML_PUSH_WARNINGS static_assert(true)
827#endif
828#ifndef TOML_DISABLE_CODE_ANALYSIS_WARNINGS
829#define TOML_DISABLE_CODE_ANALYSIS_WARNINGS static_assert(true)
830#endif
831#ifndef TOML_DISABLE_SWITCH_WARNINGS
832#define TOML_DISABLE_SWITCH_WARNINGS static_assert(true)
833#endif
834#ifndef TOML_DISABLE_SUGGEST_ATTR_WARNINGS
835#define TOML_DISABLE_SUGGEST_ATTR_WARNINGS static_assert(true)
836#endif
837#ifndef TOML_DISABLE_SPAM_WARNINGS
838#define TOML_DISABLE_SPAM_WARNINGS static_assert(true)
839#endif
840#ifndef TOML_DISABLE_ARITHMETIC_WARNINGS
841#define TOML_DISABLE_ARITHMETIC_WARNINGS static_assert(true)
842#endif
843#ifndef TOML_POP_WARNINGS
844#define TOML_POP_WARNINGS static_assert(true)
845#endif
846#ifndef TOML_DISABLE_WARNINGS
847#define TOML_DISABLE_WARNINGS static_assert(true)
848#endif
849#ifndef TOML_ENABLE_WARNINGS
850#define TOML_ENABLE_WARNINGS static_assert(true)
851#endif
852#ifndef TOML_SIMPLE_STATIC_ASSERT_MESSAGES
853#define TOML_SIMPLE_STATIC_ASSERT_MESSAGES 0
854#endif
855
856// #====================================================================================================================
857// # USER CONFIGURATION
858// #====================================================================================================================
865
866#ifdef TOML_CONFIG_HEADER
867#include TOML_CONFIG_HEADER
868#endif
869// # {{
870#if TOML_DOXYGEN
871#define TOML_CONFIG_HEADER
872#endif
876// # }}
877
878// is the library being built as a shared lib/dll using meson and friends?
879#ifndef TOML_SHARED_LIB
880#define TOML_SHARED_LIB 0
881#endif
882
883// header-only mode
884#if !defined(TOML_HEADER_ONLY) && defined(TOML_ALL_INLINE) // was TOML_ALL_INLINE pre-2.0
885#define TOML_HEADER_ONLY TOML_ALL_INLINE
886#endif
887#if !defined(TOML_HEADER_ONLY) || (defined(TOML_HEADER_ONLY) && TOML_HEADER_ONLY) || \
888 TOML_INTELLISENSE
889#undef TOML_HEADER_ONLY
890#define TOML_HEADER_ONLY 1
891#endif
892#if TOML_DOXYGEN || TOML_SHARED_LIB
893#undef TOML_HEADER_ONLY
894#define TOML_HEADER_ONLY 0
895#endif
910
911// internal implementation switch
912#if defined(TOML_IMPLEMENTATION) || TOML_HEADER_ONLY
913#undef TOML_IMPLEMENTATION
914#define TOML_IMPLEMENTATION 1
915#else
916#define TOML_IMPLEMENTATION 0
917#endif
921
922// dll/shared lib function exports (legacy - TOML_API was the old name for this setting)
923#if !defined(TOML_EXPORTED_MEMBER_FUNCTION) && !defined(TOML_EXPORTED_STATIC_FUNCTION) && \
924 !defined(TOML_EXPORTED_FREE_FUNCTION) && !defined(TOML_EXPORTED_CLASS) && defined(TOML_API)
925#define TOML_EXPORTED_MEMBER_FUNCTION TOML_API
926#define TOML_EXPORTED_STATIC_FUNCTION TOML_API
927#define TOML_EXPORTED_FREE_FUNCTION TOML_API
928#endif
929
930// dll/shared lib exports
931#if TOML_SHARED_LIB
932#undef TOML_API
933#undef TOML_EXPORTED_CLASS
934#undef TOML_EXPORTED_MEMBER_FUNCTION
935#undef TOML_EXPORTED_STATIC_FUNCTION
936#undef TOML_EXPORTED_FREE_FUNCTION
937#if TOML_WINDOWS
938#if TOML_IMPLEMENTATION
939#define TOML_EXPORTED_CLASS __declspec(dllexport)
940#define TOML_EXPORTED_FREE_FUNCTION __declspec(dllexport)
941#else
942#define TOML_EXPORTED_CLASS __declspec(dllimport)
943#define TOML_EXPORTED_FREE_FUNCTION __declspec(dllimport)
944#endif
945#ifndef TOML_CALLCONV
946#define TOML_CALLCONV __cdecl
947#endif
948#elif defined(__GNUC__) && __GNUC__ >= 4
949#define TOML_EXPORTED_CLASS __attribute__((visibility("default")))
950#define TOML_EXPORTED_MEMBER_FUNCTION __attribute__((visibility("default")))
951#define TOML_EXPORTED_STATIC_FUNCTION __attribute__((visibility("default")))
952#define TOML_EXPORTED_FREE_FUNCTION __attribute__((visibility("default")))
953#endif
954#endif
955#ifndef TOML_EXPORTED_CLASS
956#define TOML_EXPORTED_CLASS
957#endif
958#ifndef TOML_EXPORTED_MEMBER_FUNCTION
959#define TOML_EXPORTED_MEMBER_FUNCTION
960#endif
961#ifndef TOML_EXPORTED_STATIC_FUNCTION
962#define TOML_EXPORTED_STATIC_FUNCTION
963#endif
964#ifndef TOML_EXPORTED_FREE_FUNCTION
965#define TOML_EXPORTED_FREE_FUNCTION
966#endif
990
991// experimental language features
992#if !defined(TOML_ENABLE_UNRELEASED_FEATURES) && \
993 defined(TOML_UNRELEASED_FEATURES) // was TOML_UNRELEASED_FEATURES
994 // pre-3.0
995#define TOML_ENABLE_UNRELEASED_FEATURES TOML_UNRELEASED_FEATURES
996#endif
997#if (defined(TOML_ENABLE_UNRELEASED_FEATURES) && TOML_ENABLE_UNRELEASED_FEATURES) || \
998 TOML_INTELLISENSE
999#undef TOML_ENABLE_UNRELEASED_FEATURES
1000#define TOML_ENABLE_UNRELEASED_FEATURES 1
1001#endif
1002#ifndef TOML_ENABLE_UNRELEASED_FEATURES
1003#define TOML_ENABLE_UNRELEASED_FEATURES 0
1004#endif
1011
1012// parser
1013#if !defined(TOML_ENABLE_PARSER) && defined(TOML_PARSER) // was TOML_PARSER pre-3.0
1014#define TOML_ENABLE_PARSER TOML_PARSER
1015#endif
1016#if !defined(TOML_ENABLE_PARSER) || (defined(TOML_ENABLE_PARSER) && TOML_ENABLE_PARSER) || \
1017 TOML_INTELLISENSE
1018#undef TOML_ENABLE_PARSER
1019#define TOML_ENABLE_PARSER 1
1020#endif
1026
1027// formatters
1028#if !defined(TOML_ENABLE_FORMATTERS) || \
1029 (defined(TOML_ENABLE_FORMATTERS) && TOML_ENABLE_FORMATTERS) || TOML_INTELLISENSE
1030#undef TOML_ENABLE_FORMATTERS
1031#define TOML_ENABLE_FORMATTERS 1
1032#endif
1042
1043// SIMD
1044#if !defined(TOML_ENABLE_SIMD) || (defined(TOML_ENABLE_SIMD) && TOML_ENABLE_SIMD) || \
1045 TOML_INTELLISENSE
1046#undef TOML_ENABLE_SIMD
1047#define TOML_ENABLE_SIMD 1
1048#endif
1049
1050// windows compat
1051#if !defined(TOML_ENABLE_WINDOWS_COMPAT) && \
1052 defined(TOML_WINDOWS_COMPAT) // was TOML_WINDOWS_COMPAT pre-3.0
1053#define TOML_ENABLE_WINDOWS_COMPAT TOML_WINDOWS_COMPAT
1054#endif
1055#if !defined(TOML_ENABLE_WINDOWS_COMPAT) || \
1056 (defined(TOML_ENABLE_WINDOWS_COMPAT) && TOML_ENABLE_WINDOWS_COMPAT) || TOML_INTELLISENSE
1057#undef TOML_ENABLE_WINDOWS_COMPAT
1058#define TOML_ENABLE_WINDOWS_COMPAT 1
1059#endif
1061#if !TOML_WINDOWS
1062#undef TOML_ENABLE_WINDOWS_COMPAT
1063#define TOML_ENABLE_WINDOWS_COMPAT 0
1064#endif
1066#ifndef TOML_INCLUDE_WINDOWS_H
1067#define TOML_INCLUDE_WINDOWS_H 0
1068#endif
1079
1080// custom optional
1081#ifdef TOML_OPTIONAL_TYPE
1082#define TOML_HAS_CUSTOM_OPTIONAL_TYPE 1
1083#else
1084#define TOML_HAS_CUSTOM_OPTIONAL_TYPE 0
1085#endif
1086// # {{
1087#if TOML_DOXYGEN
1088#define TOML_OPTIONAL_TYPE
1089#endif
1096// # }}
1097
1098// exceptions (library use)
1099#if TOML_COMPILER_HAS_EXCEPTIONS
1100#if !defined(TOML_EXCEPTIONS) || (defined(TOML_EXCEPTIONS) && TOML_EXCEPTIONS)
1101#undef TOML_EXCEPTIONS
1102#define TOML_EXCEPTIONS 1
1103#endif
1104#else
1105#if defined(TOML_EXCEPTIONS) && TOML_EXCEPTIONS
1106#error TOML_EXCEPTIONS was explicitly enabled but exceptions are disabled/unsupported by the compiler.
1107#endif
1108#undef TOML_EXCEPTIONS
1109#define TOML_EXCEPTIONS 0
1110#endif
1114
1115// calling convention for static/free/friend functions
1116#ifndef TOML_CALLCONV
1117#define TOML_CALLCONV
1118#endif
1122
1123// # {{
1124#if TOML_DOXYGEN
1125#define TOML_SMALL_FLOAT_TYPE
1126#endif
1131// # }}
1132
1133#ifndef TOML_UNDEF_MACROS
1134#define TOML_UNDEF_MACROS 1
1135#endif
1136
1137#ifndef TOML_MAX_NESTED_VALUES
1138#define TOML_MAX_NESTED_VALUES 256
1139// this refers to the depth of nested values, e.g. inline tables and arrays.
1140// 256 is crazy high! if you're hitting this limit with real input, TOML is probably the wrong tool
1141// for the job...
1142#endif
1143
1144#ifdef TOML_CHAR_8_STRINGS
1145#if TOML_CHAR_8_STRINGS
1146#error TOML_CHAR_8_STRINGS was removed in toml++ 2.0.0; all value setters and getters now work with char8_t strings implicitly.
1147#endif
1148#endif
1149
1150#ifdef TOML_LARGE_FILES
1151#if !TOML_LARGE_FILES
1152#error Support for !TOML_LARGE_FILES (i.e. 'small files') was removed in toml++ 3.0.0.
1153#endif
1154#endif
1155
1156#ifndef TOML_LIFETIME_HOOKS
1157#define TOML_LIFETIME_HOOKS 0
1158#endif
1159
1160#ifdef NDEBUG
1161#undef TOML_ASSERT
1162#define TOML_ASSERT(expr) static_assert(true)
1163#endif
1164#ifndef TOML_ASSERT
1165#ifndef assert
1167#include <cassert>
1169#endif
1170#define TOML_ASSERT(expr) assert(expr)
1171#endif
1172#ifdef NDEBUG
1173#define TOML_ASSERT_ASSUME(expr) TOML_ASSUME(expr)
1174#else
1175#define TOML_ASSERT_ASSUME(expr) TOML_ASSERT(expr)
1176#endif
1180
1181// # {{
1182#if TOML_DOXYGEN
1183#define TOML_SMALL_INT_TYPE
1184#endif
1189// # }}
1190
1191#ifndef TOML_ENABLE_FLOAT16
1192#define TOML_ENABLE_FLOAT16 0
1193#endif
1194// # {{
1198// # }}
1199
1201// #====================================================================================================================
1202// # CHARCONV SUPPORT
1203// #====================================================================================================================
1204
1205#if !defined(TOML_FLOAT_CHARCONV) && (TOML_GCC || TOML_CLANG || (TOML_ICC && !TOML_ICC_CL))
1206// not supported by any version of GCC or Clang as of 26/11/2020
1207// not supported by any version of ICC on Linux as of 11/01/2021
1208#define TOML_FLOAT_CHARCONV 0
1209#endif
1210#if !defined(TOML_INT_CHARCONV) && (defined(__EMSCRIPTEN__) || defined(__APPLE__))
1211// causes link errors on emscripten
1212// causes Mac OS SDK version errors on some versions of Apple Clang
1213#define TOML_INT_CHARCONV 0
1214#endif
1215#ifndef TOML_INT_CHARCONV
1216#define TOML_INT_CHARCONV 1
1217#endif
1218#ifndef TOML_FLOAT_CHARCONV
1219#define TOML_FLOAT_CHARCONV 1
1220#endif
1221#if (TOML_INT_CHARCONV || TOML_FLOAT_CHARCONV) && !TOML_HAS_INCLUDE(<charconv>)
1222#undef TOML_INT_CHARCONV
1223#undef TOML_FLOAT_CHARCONV
1224#define TOML_INT_CHARCONV 0
1225#define TOML_FLOAT_CHARCONV 0
1226#endif
1227
1228// #=====================================================================================================================
1229// # SFINAE
1230// #=====================================================================================================================
1231
1233#if defined(__cpp_concepts) && __cpp_concepts >= 201907
1234#define TOML_REQUIRES(...) requires(__VA_ARGS__)
1235#else
1236#define TOML_REQUIRES(...)
1237#endif
1238#define TOML_ENABLE_IF(...) , typename std::enable_if<(__VA_ARGS__), int>::type = 0
1239#define TOML_CONSTRAINED_TEMPLATE(condition, ...) \
1240 template <__VA_ARGS__ TOML_ENABLE_IF(condition)> \
1241 TOML_REQUIRES(condition)
1242#define TOML_HIDDEN_CONSTRAINT(condition, ...) TOML_CONSTRAINED_TEMPLATE(condition, __VA_ARGS__)
1244// # {{
1245#ifndef TOML_CONSTRAINED_TEMPLATE
1246#define TOML_CONSTRAINED_TEMPLATE(condition, ...) template <__VA_ARGS__>
1247#endif
1248#ifndef TOML_HIDDEN_CONSTRAINT
1249#define TOML_HIDDEN_CONSTRAINT(condition, ...)
1250#endif
1251// # }}
1252
1253// #=====================================================================================================================
1254// # FLOAT128
1255// #=====================================================================================================================
1256
1257#if defined(__SIZEOF_FLOAT128__) && defined(__FLT128_MANT_DIG__) && defined(__LDBL_MANT_DIG__) && \
1258 __FLT128_MANT_DIG__ > __LDBL_MANT_DIG__
1259#define TOML_FLOAT128 __float128
1260#endif
1261
1262// #=====================================================================================================================
1263// # INT128
1264// #=====================================================================================================================
1265
1266#ifdef __SIZEOF_INT128__
1267#define TOML_INT128 __int128_t
1268#define TOML_UINT128 __uint128_t
1269#endif
1270
1271// #====================================================================================================================
1272// # VERSIONS AND NAMESPACES
1273// #====================================================================================================================
1274// clang-format off
1275
1276#include "version.hpp"
1277
1278#define TOML_LIB_SINGLE_HEADER 0
1279
1280#if TOML_ENABLE_UNRELEASED_FEATURES
1281 #define TOML_LANG_EFFECTIVE_VERSION \
1282 TOML_MAKE_VERSION(TOML_LANG_MAJOR, TOML_LANG_MINOR, TOML_LANG_PATCH+1)
1283#else
1284 #define TOML_LANG_EFFECTIVE_VERSION \
1285 TOML_MAKE_VERSION(TOML_LANG_MAJOR, TOML_LANG_MINOR, TOML_LANG_PATCH)
1286#endif
1287
1288#define TOML_LANG_HIGHER_THAN(major, minor, patch) \
1289 (TOML_LANG_EFFECTIVE_VERSION > TOML_MAKE_VERSION(major, minor, patch))
1290
1291#define TOML_LANG_AT_LEAST(major, minor, patch) \
1292 (TOML_LANG_EFFECTIVE_VERSION >= TOML_MAKE_VERSION(major, minor, patch))
1293
1294#define TOML_LANG_UNRELEASED \
1295 TOML_LANG_HIGHER_THAN(TOML_LANG_MAJOR, TOML_LANG_MINOR, TOML_LANG_PATCH)
1296
1297#ifndef TOML_ABI_NAMESPACES
1298 #if TOML_DOXYGEN
1299 #define TOML_ABI_NAMESPACES 0
1300 #else
1301 #define TOML_ABI_NAMESPACES 1
1302 #endif
1303#endif
1304#if TOML_ABI_NAMESPACES
1305 #define TOML_NAMESPACE_START namespace toml { inline namespace TOML_CONCAT(v, TOML_LIB_MAJOR)
1306 #define TOML_NAMESPACE_END } static_assert(true)
1307 #define TOML_NAMESPACE ::toml::TOML_CONCAT(v, TOML_LIB_MAJOR)
1308 #define TOML_ABI_NAMESPACE_START(name) inline namespace name { static_assert(true)
1309 #define TOML_ABI_NAMESPACE_BOOL(cond, T, F) TOML_ABI_NAMESPACE_START(TOML_CONCAT(TOML_EVAL_BOOL_, cond)(T, F))
1310 #define TOML_ABI_NAMESPACE_END } static_assert(true)
1311#else
1312 #define TOML_NAMESPACE_START namespace toml
1313 #define TOML_NAMESPACE_END static_assert(true)
1314 #define TOML_NAMESPACE toml
1315 #define TOML_ABI_NAMESPACE_START(...) static_assert(true)
1316 #define TOML_ABI_NAMESPACE_BOOL(...) static_assert(true)
1317 #define TOML_ABI_NAMESPACE_END static_assert(true)
1318#endif
1319#define TOML_IMPL_NAMESPACE_START TOML_NAMESPACE_START { namespace impl
1320#define TOML_IMPL_NAMESPACE_END } TOML_NAMESPACE_END
1321#if TOML_HEADER_ONLY
1322 #define TOML_ANON_NAMESPACE_START static_assert(TOML_IMPLEMENTATION); TOML_IMPL_NAMESPACE_START
1323 #define TOML_ANON_NAMESPACE_END TOML_IMPL_NAMESPACE_END
1324 #define TOML_ANON_NAMESPACE TOML_NAMESPACE::impl
1325 #define TOML_EXTERNAL_LINKAGE inline
1326 #define TOML_INTERNAL_LINKAGE inline
1327#else
1328 #define TOML_ANON_NAMESPACE_START static_assert(TOML_IMPLEMENTATION); \
1329 using namespace toml; \
1330 namespace
1331 #define TOML_ANON_NAMESPACE_END static_assert(true)
1332 #define TOML_ANON_NAMESPACE
1333 #define TOML_EXTERNAL_LINKAGE
1334 #define TOML_INTERNAL_LINKAGE static
1335#endif
1336
1337// clang-format on
1338// #====================================================================================================================
1339// # ASSERT
1340// #====================================================================================================================
1341
1342// #====================================================================================================================
1343// # STATIC ASSERT MESSAGE FORMATTING
1344// #====================================================================================================================
1345// clang-format off
1347
1348#if TOML_SIMPLE_STATIC_ASSERT_MESSAGES
1349
1350 #define TOML_SA_NEWLINE " "
1351 #define TOML_SA_LIST_SEP ", "
1352 #define TOML_SA_LIST_BEG " ("
1353 #define TOML_SA_LIST_END ")"
1354 #define TOML_SA_LIST_NEW " "
1355 #define TOML_SA_LIST_NXT ", "
1356
1357#else
1358
1359 #define TOML_SA_NEWLINE "\n| "
1360 #define TOML_SA_LIST_SEP TOML_SA_NEWLINE " - "
1361 #define TOML_SA_LIST_BEG TOML_SA_LIST_SEP
1362 #define TOML_SA_LIST_END
1363 #define TOML_SA_LIST_NEW TOML_SA_NEWLINE TOML_SA_NEWLINE
1364 #define TOML_SA_LIST_NXT TOML_SA_LIST_NEW
1365
1366#endif
1367
1368#define TOML_SA_NATIVE_VALUE_TYPE_LIST \
1369 TOML_SA_LIST_BEG "std::string" \
1370 TOML_SA_LIST_SEP "int64_t" \
1371 TOML_SA_LIST_SEP "double" \
1372 TOML_SA_LIST_SEP "bool" \
1373 TOML_SA_LIST_SEP "toml::date" \
1374 TOML_SA_LIST_SEP "toml::time" \
1375 TOML_SA_LIST_SEP "toml::date_time" \
1376 TOML_SA_LIST_END
1377
1378#define TOML_SA_NODE_TYPE_LIST \
1379 TOML_SA_LIST_BEG "toml::table" \
1380 TOML_SA_LIST_SEP "toml::array" \
1381 TOML_SA_LIST_SEP "toml::value<std::string>" \
1382 TOML_SA_LIST_SEP "toml::value<int64_t>" \
1383 TOML_SA_LIST_SEP "toml::value<double>" \
1384 TOML_SA_LIST_SEP "toml::value<bool>" \
1385 TOML_SA_LIST_SEP "toml::value<toml::date>" \
1386 TOML_SA_LIST_SEP "toml::value<toml::time>" \
1387 TOML_SA_LIST_SEP "toml::value<toml::date_time>" \
1388 TOML_SA_LIST_END
1389
1390#define TOML_SA_UNWRAPPED_NODE_TYPE_LIST \
1391 TOML_SA_LIST_NEW "A native TOML value type" \
1392 TOML_SA_NATIVE_VALUE_TYPE_LIST \
1393 \
1394 TOML_SA_LIST_NXT "A TOML node type" \
1395 TOML_SA_NODE_TYPE_LIST
1396
1398// clang-format on
#define TOML_DISABLE_WARNINGS
#define TOML_ENABLE_WARNINGS