diff --git a/.clang-format b/.clang-format index 5b9e3fd530..a62584e649 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,3 @@ -#AccessModifierOffset: 2 AlignAfterOpenBracket: Align AlignConsecutiveAssignments: false #AlignConsecutiveBitFields: false @@ -12,7 +11,7 @@ AllowAllConstructorInitializersOnNextLine: false AllowAllParametersOfDeclarationOnNextLine: false AllowShortBlocksOnASingleLine: Empty AllowShortCaseLabelsOnASingleLine: false -#AllowShortEnumsOnASingleLine: true +AllowShortEnumsOnASingleLine: true AllowShortFunctionsOnASingleLine: Empty AllowShortIfStatementsOnASingleLine: Never AllowShortLambdasOnASingleLine: Empty @@ -30,27 +29,26 @@ BraceWrapping: AfterControlStatement: Always AfterEnum: true AfterFunction: true - AfterNamespace: false + AfterNamespace: true AfterStruct: true AfterUnion: true AfterExternBlock: false BeforeCatch: true BeforeElse: true - #BeforeLambdaBody: false - #BeforeWhile: false + BeforeLambdaBody: false + BeforeWhile: false SplitEmptyFunction: false SplitEmptyRecord: false SplitEmptyNamespace: false BreakBeforeTernaryOperators: true BreakConstructorInitializers: BeforeComma BreakStringLiterals: false -ColumnLimit: 0 +ColumnLimit: 160 CompactNamespaces: false ConstructorInitializerIndentWidth: 2 -Cpp11BracedListStyle: true +Cpp11BracedListStyle: false PointerAlignment: Left FixNamespaceComments: true -IncludeBlocks: Preserve #IndentCaseBlocks: false IndentCaseLabels: true IndentGotoLabels: false @@ -60,7 +58,6 @@ KeepEmptyLinesAtTheStartOfBlocks: false MaxEmptyLinesToKeep: 1 NamespaceIndentation: None ReflowComments: false -SortIncludes: true SortUsingDeclarations: true SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false @@ -79,6 +76,22 @@ SpacesInConditionalStatement: false SpacesInContainerLiterals: false SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: c++11 +Standard: Latest TabWidth: 4 UseTab: Never + +# what to do with include blocks +SortIncludes: true +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^".*"' + Priority: 1 + - Regex: '<[^\/]+>' + Priority: 2 + - Regex: '^<(nlohmann)\/-*' + Priority: 3 + - Regex: '.*' + Priority: 4 + +Macros: + - JSON_PRIVATE_UNLESS_TESTED=private diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 4d33c67bf2..3e078b3444 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -50,7 +50,7 @@ To make changes, you need to edit the following files: ## Note - If you open a pull request, the code will be automatically tested with [Valgrind](http://valgrind.org)'s Memcheck tool to detect memory leaks. Please be aware that the execution with Valgrind _may_ in rare cases yield different behavior than running the code directly. This can result in failing unit tests which run successfully without Valgrind. -- There is a Makefile target `make pretty` which runs [Artistic Style](http://astyle.sourceforge.net) to fix indentation. If possible, run it before opening the pull request. Otherwise, we shall run it afterward. +- There is a Makefile target `make pretty` which runs [Clang-Format](https://clang.llvm.org/docs/ClangFormat.html) to fix indentation. If possible, run it before opening the pull request. Otherwise, we shall run it afterward. ## Please don't diff --git a/.github/workflows/check_amalgamation.yml b/.github/workflows/check_amalgamation.yml index 0fadb52065..3054c6d515 100644 --- a/.github/workflows/check_amalgamation.yml +++ b/.github/workflows/check_amalgamation.yml @@ -21,15 +21,9 @@ jobs: check: runs-on: ubuntu-latest + container: silkeh/clang:dev env: MAIN_DIR: ${{ github.workspace }}/main - INCLUDE_DIR: ${{ github.workspace }}/main/single_include/nlohmann - TOOL_DIR: ${{ github.workspace }}/tools/tools/amalgamate - ASTYLE_FLAGS: > - --style=allman --indent=spaces=4 --indent-modifiers --indent-switches --indent-preproc-block - --indent-preproc-define --indent-col1-comments --pad-oper --pad-header --align-pointer=type - --align-reference=type --add-brackets --convert-tabs --close-templates --lineend=linux --preserve-date - --formatted steps: - name: Checkout pull request @@ -44,27 +38,7 @@ jobs: path: tools ref: develop - - name: Install astyle - run: | - sudo apt-get update - sudo apt-get install astyle - - name: Check amalgamation run: | cd $MAIN_DIR - - rm -fr $INCLUDE_DIR/json.hpp~ $INCLUDE_DIR/json_fwd.hpp~ - cp $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json.hpp~ - cp $INCLUDE_DIR/json_fwd.hpp $INCLUDE_DIR/json_fwd.hpp~ - - python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json.json -s . - python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json_fwd.json -s . - echo "Format (1)" - astyle $ASTYLE_FLAGS --suffix=none --quiet $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json_fwd.hpp - - diff $INCLUDE_DIR/json.hpp~ $INCLUDE_DIR/json.hpp - diff $INCLUDE_DIR/json_fwd.hpp~ $INCLUDE_DIR/json_fwd.hpp - - astyle $ASTYLE_FLAGS $(find docs/examples include tests -type f \( -name '*.hpp' -o -name '*.cpp' -o -name '*.cu' \) -not -path 'tests/thirdparty/*' -not -path 'tests/abi/include/nlohmann/*' | sort) - echo Check - find $MAIN_DIR -name '*.orig' -exec false {} \+ + make check-amalgamation diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 35fb9573cc..ad35aa9758 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -46,7 +46,7 @@ jobs: container: ghcr.io/nlohmann/json-ci:v2.4.0 strategy: matrix: - target: [ci_cppcheck, ci_test_valgrind, ci_test_amalgamation, ci_test_single_header, ci_single_binaries, ci_infer] + target: [ci_cppcheck, ci_test_valgrind, ci_test_single_header, ci_single_binaries, ci_infer] steps: - uses: actions/checkout@v3 - name: Run CMake @@ -54,6 +54,18 @@ jobs: - name: Build run: cmake --build build --target ${{ matrix.target }} + ci_test_amalgamation: + runs-on: ubuntu-latest + container: silkeh/clang:dev + steps: + - uses: actions/checkout@v3 + - name: Get latest CMake and ninja + uses: lukka/get-cmake@v3.27.7 + - name: Run CMake + run: cmake -S . -B build -DJSON_CI=On + - name: Build + run: cmake --build build --target ci_test_amalgamation + ci_static_analysis_ubuntu: runs-on: ubuntu-latest strategy: diff --git a/Makefile b/Makefile index a1b4e7328e..9c0cfe52d1 100644 --- a/Makefile +++ b/Makefile @@ -142,33 +142,9 @@ pvs_studio: # Code format and source amalgamation ########################################################################## -# call the Artistic Style pretty printer on all source files -pretty: - astyle \ - --style=allman \ - --indent=spaces=4 \ - --indent-modifiers \ - --indent-switches \ - --indent-preproc-block \ - --indent-preproc-define \ - --indent-col1-comments \ - --pad-oper \ - --pad-header \ - --align-pointer=type \ - --align-reference=type \ - --add-braces \ - --squeeze-lines=2 \ - --convert-tabs \ - --close-templates \ - --lineend=linux \ - --preserve-date \ - --suffix=none \ - --formatted \ - $(SRCS) $(TESTS_SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) docs/examples/*.cpp - # call the Clang-Format on all source files -pretty_format: - for FILE in $(SRCS) $(TESTS_SRCS) $(AMALGAMATED_FILE) docs/examples/*.cpp; do echo $$FILE; clang-format -i $$FILE; done +pretty: + clang-format --Werror --verbose -i $(SRCS) $(TESTS_SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) # create single header files and pretty print amalgamate: $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) diff --git a/README.md b/README.md index 9109027062..91c4774177 100644 --- a/README.md +++ b/README.md @@ -1774,8 +1774,8 @@ The library itself consists of a single header file licensed under the MIT licen - [**amalgamate.py - Amalgamate C source and header files**](https://github.com/edlund/amalgamate) to create a single header file - [**American fuzzy lop**](https://lcamtuf.coredump.cx/afl/) for fuzz testing - [**AppVeyor**](https://www.appveyor.com) for [continuous integration](https://ci.appveyor.com/project/nlohmann/json) on Windows -- [**Artistic Style**](http://astyle.sourceforge.net) for automatic source code indentation - [**Clang**](https://clang.llvm.org) for compilation with code sanitizers +- [**Clang-Format**](https://clang.llvm.org/docs/ClangFormat.html) for automatic source code indentation - [**CMake**](https://cmake.org) for build automation - [**Codacy**](https://www.codacy.com) for further [code analysis](https://www.codacy.com/app/nlohmann/json) - [**Coveralls**](https://coveralls.io) to measure [code coverage](https://coveralls.io/github/nlohmann/json) diff --git a/cmake/ci.cmake b/cmake/ci.cmake index bbb2d4cb95..df977ebd43 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -8,16 +8,16 @@ set(N 10) include(FindPython3) find_package(Python3 COMPONENTS Interpreter) -find_program(ASTYLE_TOOL NAMES astyle) -execute_process(COMMAND ${ASTYLE_TOOL} --version OUTPUT_VARIABLE ASTYLE_TOOL_VERSION ERROR_VARIABLE ASTYLE_TOOL_VERSION) -string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" ASTYLE_TOOL_VERSION "${ASTYLE_TOOL_VERSION}") -message(STATUS "🔖 Artistic Style ${ASTYLE_TOOL_VERSION} (${ASTYLE_TOOL})") - find_program(CLANG_TOOL NAMES clang++-HEAD clang++ clang++-17 clang++-16 clang++-15 clang++-14 clang++-13 clang++-12 clang++-11 clang++) execute_process(COMMAND ${CLANG_TOOL} --version OUTPUT_VARIABLE CLANG_TOOL_VERSION ERROR_VARIABLE CLANG_TOOL_VERSION) string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TOOL_VERSION "${CLANG_TOOL_VERSION}") message(STATUS "🔖 Clang ${CLANG_TOOL_VERSION} (${CLANG_TOOL})") +find_program(CLANG_FORMAT_TOOL NAMES clang-format) +execute_process(COMMAND ${CLANG_FORMAT_TOOL} --version OUTPUT_VARIABLE CLANG_FORMAT_TOOL_VERSION ERROR_VARIABLE CLANG_FORMAT_TOOL_VERSION) +string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_FORMAT_TOOL_VERSION "${CLANG_FORMAT_TOOL_VERSION}") +message(STATUS "🔖 Clang-Format ${CLANG_FORMAT_TOOL_VERSION} (${CLANG_FORMAT_TOOL})") + find_program(CLANG_TIDY_TOOL NAMES clang-tidy-17 clang-tidy-16 clang-tidy-15 clang-tidy-14 clang-tidy-13 clang-tidy-12 clang-tidy-11 clang-tidy) execute_process(COMMAND ${CLANG_TIDY_TOOL} --version OUTPUT_VARIABLE CLANG_TIDY_TOOL_VERSION ERROR_VARIABLE CLANG_TIDY_TOOL_VERSION) string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TIDY_TOOL_VERSION "${CLANG_TIDY_TOOL_VERSION}") @@ -581,33 +581,8 @@ add_custom_target(ci_test_clang_sanitizer # Check if header is amalgamated and sources are properly indented. ############################################################################### -set(ASTYLE_FLAGS --style=allman --indent=spaces=4 --indent-modifiers --indent-switches --indent-preproc-block --indent-preproc-define --indent-col1-comments --pad-oper --pad-header --align-pointer=type --align-reference=type --add-brackets --convert-tabs --close-templates --lineend=linux --preserve-date --formatted) - -file(GLOB_RECURSE INDENT_FILES - ${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp - ${PROJECT_SOURCE_DIR}/tests/src/*.cpp - ${PROJECT_SOURCE_DIR}/tests/src/*.hpp - ${PROJECT_SOURCE_DIR}/tests/benchmarks/src/benchmarks.cpp - ${PROJECT_SOURCE_DIR}/docs/examples/*.cpp -) - -set(include_dir ${PROJECT_SOURCE_DIR}/single_include/nlohmann) -set(tool_dir ${PROJECT_SOURCE_DIR}/tools/amalgamate) add_custom_target(ci_test_amalgamation - COMMAND rm -fr ${include_dir}/json.hpp~ ${include_dir}/json_fwd.hpp~ - COMMAND cp ${include_dir}/json.hpp ${include_dir}/json.hpp~ - COMMAND cp ${include_dir}/json_fwd.hpp ${include_dir}/json_fwd.hpp~ - - COMMAND ${Python3_EXECUTABLE} ${tool_dir}/amalgamate.py -c ${tool_dir}/config_json.json -s . - COMMAND ${Python3_EXECUTABLE} ${tool_dir}/amalgamate.py -c ${tool_dir}/config_json_fwd.json -s . - COMMAND ${ASTYLE_TOOL} ${ASTYLE_FLAGS} --suffix=none --quiet ${include_dir}/json.hpp ${include_dir}/json_fwd.hpp - - COMMAND diff ${include_dir}/json.hpp~ ${include_dir}/json.hpp - COMMAND diff ${include_dir}/json_fwd.hpp~ ${include_dir}/json_fwd.hpp - - COMMAND ${ASTYLE_TOOL} ${ASTYLE_FLAGS} ${INDENT_FILES} - COMMAND for FILE in `find . -name '*.orig'`\; do false \; done - + COMMAND make check-amalgamation WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMENT "Check amalgamation and indentation" ) diff --git a/include/nlohmann/adl_serializer.hpp b/include/nlohmann/adl_serializer.hpp index 56a606c0f6..95b0722e78 100644 --- a/include/nlohmann/adl_serializer.hpp +++ b/include/nlohmann/adl_serializer.hpp @@ -24,9 +24,8 @@ struct adl_serializer /// @brief convert a JSON value to any value type /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/ template - static auto from_json(BasicJsonType && j, TargetType& val) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), val))) - -> decltype(::nlohmann::from_json(std::forward(j), val), void()) + static auto from_json(BasicJsonType&& j, TargetType& val) noexcept(noexcept(::nlohmann::from_json(std::forward(j), val))) + -> decltype(::nlohmann::from_json(std::forward(j), val), void()) { ::nlohmann::from_json(std::forward(j), val); } @@ -34,19 +33,17 @@ struct adl_serializer /// @brief convert a JSON value to any value type /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/ template - static auto from_json(BasicJsonType && j) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), detail::identity_tag {}))) - -> decltype(::nlohmann::from_json(std::forward(j), detail::identity_tag {})) + static auto from_json(BasicJsonType&& j) noexcept(noexcept(::nlohmann::from_json(std::forward(j), detail::identity_tag{}))) + -> decltype(::nlohmann::from_json(std::forward(j), detail::identity_tag{})) { - return ::nlohmann::from_json(std::forward(j), detail::identity_tag {}); + return ::nlohmann::from_json(std::forward(j), detail::identity_tag{}); } /// @brief convert any value type to a JSON value /// @sa https://json.nlohmann.me/api/adl_serializer/to_json/ template - static auto to_json(BasicJsonType& j, TargetType && val) noexcept( - noexcept(::nlohmann::to_json(j, std::forward(val)))) - -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) + static auto to_json(BasicJsonType& j, TargetType&& val) noexcept(noexcept(::nlohmann::to_json(j, std::forward(val)))) + -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) { ::nlohmann::to_json(j, std::forward(val)); } diff --git a/include/nlohmann/byte_container_with_subtype.hpp b/include/nlohmann/byte_container_with_subtype.hpp index 91382cd682..20036c27f0 100644 --- a/include/nlohmann/byte_container_with_subtype.hpp +++ b/include/nlohmann/byte_container_with_subtype.hpp @@ -8,9 +8,9 @@ #pragma once -#include // uint8_t, uint64_t -#include // tie -#include // move +#include // uint8_t, uint64_t +#include // tie +#include // move #include @@ -27,31 +27,31 @@ class byte_container_with_subtype : public BinaryType /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ byte_container_with_subtype() noexcept(noexcept(container_type())) - : container_type() + : container_type() {} /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b))) - : container_type(b) + : container_type(b) {} /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b)))) - : container_type(std::move(b)) + : container_type(std::move(b)) {} /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ byte_container_with_subtype(const container_type& b, subtype_type subtype_) noexcept(noexcept(container_type(b))) - : container_type(b) - , m_subtype(subtype_) - , m_has_subtype(true) + : container_type(b) + , m_subtype(subtype_) + , m_has_subtype(true) {} /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ byte_container_with_subtype(container_type&& b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b)))) - : container_type(std::move(b)) - , m_subtype(subtype_) - , m_has_subtype(true) + : container_type(std::move(b)) + , m_subtype(subtype_) + , m_has_subtype(true) {} bool operator==(const byte_container_with_subtype& rhs) const diff --git a/include/nlohmann/detail/abi_macros.hpp b/include/nlohmann/detail/abi_macros.hpp index f48b9eb1d5..3e560bc455 100644 --- a/include/nlohmann/detail/abi_macros.hpp +++ b/include/nlohmann/detail/abi_macros.hpp @@ -47,54 +47,40 @@ #endif // Construct the namespace ABI tags component -#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b -#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \ - NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) +#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi##a##b +#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) -#define NLOHMANN_JSON_ABI_TAGS \ - NLOHMANN_JSON_ABI_TAGS_CONCAT( \ - NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ - NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) +#define NLOHMANN_JSON_ABI_TAGS NLOHMANN_JSON_ABI_TAGS_CONCAT(NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) // Construct the namespace version component -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ - _v ## major ## _ ## minor ## _ ## patch -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) _v##major##_##minor##_##patch +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) #if NLOHMANN_JSON_NAMESPACE_NO_VERSION -#define NLOHMANN_JSON_NAMESPACE_VERSION + #define NLOHMANN_JSON_NAMESPACE_VERSION #else -#define NLOHMANN_JSON_NAMESPACE_VERSION \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ - NLOHMANN_JSON_VERSION_MINOR, \ - NLOHMANN_JSON_VERSION_PATCH) + #define NLOHMANN_JSON_NAMESPACE_VERSION \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH) #endif // Combine namespace components -#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b -#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ - NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) +#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a##b +#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) #ifndef NLOHMANN_JSON_NAMESPACE -#define NLOHMANN_JSON_NAMESPACE \ - nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) + #define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT(NLOHMANN_JSON_ABI_TAGS, NLOHMANN_JSON_NAMESPACE_VERSION) #endif #ifndef NLOHMANN_JSON_NAMESPACE_BEGIN -#define NLOHMANN_JSON_NAMESPACE_BEGIN \ - namespace nlohmann \ - { \ - inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) \ - { + #define NLOHMANN_JSON_NAMESPACE_BEGIN \ + namespace nlohmann \ + { \ + inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT(NLOHMANN_JSON_ABI_TAGS, NLOHMANN_JSON_NAMESPACE_VERSION) \ + { #endif #ifndef NLOHMANN_JSON_NAMESPACE_END -#define NLOHMANN_JSON_NAMESPACE_END \ - } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ - } // namespace nlohmann + #define NLOHMANN_JSON_NAMESPACE_END \ + } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ + } // namespace nlohmann #endif diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index aa2f0cbf4c..122a5445fd 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -8,17 +8,17 @@ #pragma once -#include // transform -#include // array -#include // forward_list -#include // inserter, front_inserter, end -#include // map -#include // string -#include // tuple, make_tuple -#include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible -#include // unordered_map -#include // pair, declval -#include // valarray +#include // transform +#include // array +#include // forward_list +#include // inserter, front_inserter, end +#include // map +#include // string +#include // tuple, make_tuple +#include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible +#include // unordered_map +#include // pair, declval +#include // valarray #include #include @@ -44,10 +44,9 @@ inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n) } // overloads for basic_json template parameters -template < typename BasicJsonType, typename ArithmeticType, - enable_if_t < std::is_arithmetic::value&& - !std::is_same::value, - int > = 0 > +template::value && !std::is_same::value, int> = 0> void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) { switch (static_cast(j)) @@ -100,13 +99,12 @@ inline void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s = *j.template get_ptr(); } -template < - typename BasicJsonType, typename StringType, - enable_if_t < - std::is_assignable::value - && is_detected_exact::value - && !std::is_same::value - && !is_json_ref::value, int > = 0 > +template::value && + is_detected_exact::value && + !std::is_same::value && !is_json_ref::value, + int> = 0> inline void from_json(const BasicJsonType& j, StringType& s) { if (JSON_HEDLEY_UNLIKELY(!j.is_string())) @@ -136,8 +134,7 @@ inline void from_json(const BasicJsonType& j, typename BasicJsonType::number_int } #if !JSON_DISABLE_ENUM_SERIALIZATION -template::value, int> = 0> +template::value, int> = 0> inline void from_json(const BasicJsonType& j, EnumType& e) { typename std::underlying_type::type val; @@ -147,8 +144,7 @@ inline void from_json(const BasicJsonType& j, EnumType& e) #endif // JSON_DISABLE_ENUM_SERIALIZATION // forward_list doesn't have an insert method -template::value, int> = 0> +template::value, int> = 0> inline void from_json(const BasicJsonType& j, std::forward_list& l) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) @@ -156,16 +152,13 @@ inline void from_json(const BasicJsonType& j, std::forward_list& l JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); } l.clear(); - std::transform(j.rbegin(), j.rend(), - std::front_inserter(l), [](const BasicJsonType & i) - { + std::transform(j.rbegin(), j.rend(), std::front_inserter(l), [](const BasicJsonType& i) { return i.template get(); }); } // valarray doesn't have an insert method -template::value, int> = 0> +template::value, int> = 0> inline void from_json(const BasicJsonType& j, std::valarray& l) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) @@ -173,16 +166,14 @@ inline void from_json(const BasicJsonType& j, std::valarray& l) JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); } l.resize(j.size()); - std::transform(j.begin(), j.end(), std::begin(l), - [](const BasicJsonType & elem) - { + std::transform(j.begin(), j.end(), std::begin(l), [](const BasicJsonType& elem) { return elem.template get(); }); } template auto from_json(const BasicJsonType& j, T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) --> decltype(j.template get(), void()) + -> decltype(j.template get(), void()) { for (std::size_t i = 0; i < N; ++i) { @@ -197,9 +188,7 @@ inline void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType: } template -auto from_json_array_impl(const BasicJsonType& j, std::array& arr, - priority_tag<2> /*unused*/) --> decltype(j.template get(), void()) +auto from_json_array_impl(const BasicJsonType& j, std::array& arr, priority_tag<2> /*unused*/) -> decltype(j.template get(), void()) { for (std::size_t i = 0; i < N; ++i) { @@ -207,23 +196,17 @@ auto from_json_array_impl(const BasicJsonType& j, std::array& arr, } } -template::value, - int> = 0> +template::value, int> = 0> auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/) --> decltype( - arr.reserve(std::declval()), - j.template get(), - void()) + -> decltype(arr.reserve(std::declval()), j.template get(), void()) { using std::end; ConstructibleArrayType ret; ret.reserve(j.size()); - std::transform(j.begin(), j.end(), - std::inserter(ret, end(ret)), [](const BasicJsonType & i) - { + std::transform(j.begin(), j.end(), std::inserter(ret, end(ret)), [](const BasicJsonType& i) { // get() returns *this, this won't call a from_json // method when value_type is BasicJsonType return i.template get(); @@ -231,20 +214,15 @@ auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, p arr = std::move(ret); } -template::value, - int> = 0> -inline void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, - priority_tag<0> /*unused*/) +template::value, int> = 0> +inline void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<0> /*unused*/) { using std::end; ConstructibleArrayType ret; - std::transform( - j.begin(), j.end(), std::inserter(ret, end(ret)), - [](const BasicJsonType & i) - { + std::transform(j.begin(), j.end(), std::inserter(ret, end(ret)), [](const BasicJsonType& i) { // get() returns *this, this won't call a from_json // method when value_type is BasicJsonType return i.template get(); @@ -252,44 +230,41 @@ inline void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr = std::move(ret); } -template < typename BasicJsonType, typename ConstructibleArrayType, - enable_if_t < - is_constructible_array_type::value&& - !is_constructible_object_type::value&& - !is_constructible_string_type::value&& - !std::is_same::value&& - !is_basic_json::value, - int > = 0 > +template::value && + !is_constructible_object_type::value && + !is_constructible_string_type::value && + !std::is_same::value && !is_basic_json::value, + int> = 0> auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) --> decltype(from_json_array_impl(j, arr, priority_tag<3> {}), -j.template get(), -void()) + -> decltype(from_json_array_impl(j, arr, priority_tag<3>{}), j.template get(), void()) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); } - from_json_array_impl(j, arr, priority_tag<3> {}); + from_json_array_impl(j, arr, priority_tag<3>{}); } -template < typename BasicJsonType, typename T, std::size_t... Idx > -std::array from_json_inplace_array_impl(BasicJsonType&& j, - identity_tag> /*unused*/, index_sequence /*unused*/) +template +std::array +from_json_inplace_array_impl(BasicJsonType&& j, identity_tag> /*unused*/, index_sequence /*unused*/) { return { { std::forward(j).at(Idx).template get()... } }; } -template < typename BasicJsonType, typename T, std::size_t N > +template auto from_json(BasicJsonType&& j, identity_tag> tag) --> decltype(from_json_inplace_array_impl(std::forward(j), tag, make_index_sequence {})) + -> decltype(from_json_inplace_array_impl(std::forward(j), tag, make_index_sequence{})) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); } - return from_json_inplace_array_impl(std::forward(j), tag, make_index_sequence {}); + return from_json_inplace_array_impl(std::forward(j), tag, make_index_sequence{}); } template @@ -303,7 +278,8 @@ inline void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin = *j.template get_ptr(); } -template::value, int> = 0> inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) { @@ -315,11 +291,7 @@ inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) ConstructibleObjectType ret; const auto* inner_object = j.template get_ptr(); using value_type = typename ConstructibleObjectType::value_type; - std::transform( - inner_object->begin(), inner_object->end(), - std::inserter(ret, ret.begin()), - [](typename BasicJsonType::object_t::value_type const & p) - { + std::transform(inner_object->begin(), inner_object->end(), std::inserter(ret, ret.begin()), [](typename BasicJsonType::object_t::value_type const& p) { return value_type(p.first, p.second.template get()); }); obj = std::move(ret); @@ -329,14 +301,13 @@ inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) // (BooleanType, etc..); note: Is it really necessary to provide explicit // overloads for boolean_t etc. in case of a custom BooleanType which is not // an arithmetic type? -template < typename BasicJsonType, typename ArithmeticType, - enable_if_t < - std::is_arithmetic::value&& - !std::is_same::value&& - !std::is_same::value&& - !std::is_same::value&& - !std::is_same::value, - int > = 0 > +template::value && !std::is_same::value && + !std::is_same::value && + !std::is_same::value && + !std::is_same::value, + int> = 0> inline void from_json(const BasicJsonType& j, ArithmeticType& val) { switch (static_cast(j)) @@ -379,46 +350,48 @@ std::tuple from_json_tuple_impl_base(BasicJsonType&& j, index_sequence< return std::make_tuple(std::forward(j).at(Idx).template get()...); } -template < typename BasicJsonType, class A1, class A2 > +template std::pair from_json_tuple_impl(BasicJsonType&& j, identity_tag> /*unused*/, priority_tag<0> /*unused*/) { - return {std::forward(j).at(0).template get(), - std::forward(j).at(1).template get()}; + return { std::forward(j).at(0).template get(), std::forward(j).at(1).template get() }; } template inline void from_json_tuple_impl(BasicJsonType&& j, std::pair& p, priority_tag<1> /*unused*/) { - p = from_json_tuple_impl(std::forward(j), identity_tag> {}, priority_tag<0> {}); + p = from_json_tuple_impl(std::forward(j), identity_tag>{}, priority_tag<0>{}); } template std::tuple from_json_tuple_impl(BasicJsonType&& j, identity_tag> /*unused*/, priority_tag<2> /*unused*/) { - return from_json_tuple_impl_base(std::forward(j), index_sequence_for {}); + return from_json_tuple_impl_base(std::forward(j), index_sequence_for{}); } template inline void from_json_tuple_impl(BasicJsonType&& j, std::tuple& t, priority_tag<3> /*unused*/) { - t = from_json_tuple_impl_base(std::forward(j), index_sequence_for {}); + t = from_json_tuple_impl_base(std::forward(j), index_sequence_for{}); } template auto from_json(BasicJsonType&& j, TupleRelated&& t) --> decltype(from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3> {})) + -> decltype(from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3>{})) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); } - return from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3> {}); + return from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3>{}); } -template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, - typename = enable_if_t < !std::is_constructible < - typename BasicJsonType::string_t, Key >::value >> +template::value>> inline void from_json(const BasicJsonType& j, std::map& m) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) @@ -436,9 +409,13 @@ inline void from_json(const BasicJsonType& j, std::map::value >> +template::value>> inline void from_json(const BasicJsonType& j, std::unordered_map& m) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) @@ -471,9 +448,8 @@ inline void from_json(const BasicJsonType& j, std_fs::path& p) struct from_json_fn { template - auto operator()(const BasicJsonType& j, T&& val) const - noexcept(noexcept(from_json(j, std::forward(val)))) - -> decltype(from_json(j, std::forward(val))) + auto operator()(const BasicJsonType& j, T&& val) const noexcept(noexcept(from_json(j, std::forward(val)))) + -> decltype(from_json(j, std::forward(val))) { return from_json(j, std::forward(val)); } @@ -485,10 +461,10 @@ struct from_json_fn /// namespace to hold default `from_json` function /// to see why this is required: /// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html -namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) +namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) { #endif -JSON_INLINE_VARIABLE constexpr const auto& from_json = // NOLINT(misc-definitions-in-headers) +JSON_INLINE_VARIABLE constexpr const auto& from_json = // NOLINT(misc-definitions-in-headers) detail::static_const::value; #ifndef JSON_HAS_CPP_17 } // namespace diff --git a/include/nlohmann/detail/conversions/to_chars.hpp b/include/nlohmann/detail/conversions/to_chars.hpp index e10741c923..6ecc6e085d 100644 --- a/include/nlohmann/detail/conversions/to_chars.hpp +++ b/include/nlohmann/detail/conversions/to_chars.hpp @@ -9,12 +9,12 @@ #pragma once -#include // array -#include // signbit, isfinite -#include // intN_t, uintN_t -#include // memcpy, memmove -#include // numeric_limits -#include // conditional +#include // array +#include // signbit, isfinite +#include // intN_t, uintN_t +#include // memcpy, memmove +#include // numeric_limits +#include // conditional #include @@ -54,14 +54,17 @@ Target reinterpret_bits(const Source source) return target; } -struct diyfp // f * 2^e +struct diyfp // f * 2^e { - static constexpr int kPrecision = 64; // = q + static constexpr int kPrecision = 64; // = q std::uint64_t f = 0; int e = 0; - constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_) {} + constexpr diyfp(std::uint64_t f_, int e_) noexcept + : f(f_) + , e(e_) + {} /*! @brief returns x - y @@ -72,7 +75,7 @@ struct diyfp // f * 2^e JSON_ASSERT(x.e == y.e); JSON_ASSERT(x.f >= y.f); - return {x.f - y.f, x.e}; + return { x.f - y.f, x.e }; } /*! @@ -133,11 +136,11 @@ struct diyfp // f * 2^e // Effectively we only need to add the highest bit in p_lo to p_hi (and // Q_hi + 1 does not overflow). - Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up + Q += std::uint64_t{ 1 } << (64u - 32u - 1u); // round, ties up const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u); - return {h, x.e + y.e + 64}; + return { h, x.e + y.e + 64 }; } /*! @@ -168,7 +171,7 @@ struct diyfp // f * 2^e JSON_ASSERT(delta >= 0); JSON_ASSERT(((x.f << delta) >> delta) == x.f); - return {x.f << delta, target_exponent}; + return { x.f << delta, target_exponent }; } }; @@ -198,24 +201,21 @@ boundaries compute_boundaries(FloatType value) // If v is normalized: // value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1)) - static_assert(std::numeric_limits::is_iec559, - "internal error: dtoa_short requires an IEEE-754 floating-point implementation"); + static_assert(std::numeric_limits::is_iec559, "internal error: dtoa_short requires an IEEE-754 floating-point implementation"); - constexpr int kPrecision = std::numeric_limits::digits; // = p (includes the hidden bit) - constexpr int kBias = std::numeric_limits::max_exponent - 1 + (kPrecision - 1); - constexpr int kMinExp = 1 - kBias; - constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1) + constexpr int kPrecision = std::numeric_limits::digits; // = p (includes the hidden bit) + constexpr int kBias = std::numeric_limits::max_exponent - 1 + (kPrecision - 1); + constexpr int kMinExp = 1 - kBias; + constexpr std::uint64_t kHiddenBit = std::uint64_t{ 1 } << (kPrecision - 1); // = 2^(p-1) - using bits_type = typename std::conditional::type; + using bits_type = typename std::conditional::type; const auto bits = static_cast(reinterpret_bits(value)); const std::uint64_t E = bits >> (kPrecision - 1); const std::uint64_t F = bits & (kHiddenBit - 1); const bool is_denormal = E == 0; - const diyfp v = is_denormal - ? diyfp(F, kMinExp) - : diyfp(F + kHiddenBit, static_cast(E) - kBias); + const diyfp v = is_denormal ? diyfp(F, kMinExp) : diyfp(F + kHiddenBit, static_cast(E) - kBias); // Compute the boundaries m- and m+ of the floating-point value // v = f * 2^e. @@ -240,9 +240,8 @@ boundaries compute_boundaries(FloatType value) const bool lower_boundary_is_closer = F == 0 && E > 1; const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1); - const diyfp m_minus = lower_boundary_is_closer - ? diyfp(4 * v.f - 1, v.e - 2) // (B) - : diyfp(2 * v.f - 1, v.e - 1); // (A) + const diyfp m_minus = lower_boundary_is_closer ? diyfp(4 * v.f - 1, v.e - 2) // (B) + : diyfp(2 * v.f - 1, v.e - 1); // (A) // Determine the normalized w+ = m+. const diyfp w_plus = diyfp::normalize(m_plus); @@ -250,7 +249,7 @@ boundaries compute_boundaries(FloatType value) // Determine w- = m- such that e_(w-) = e_(w+). const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e); - return {diyfp::normalize(v), w_minus, w_plus}; + return { diyfp::normalize(v), w_minus, w_plus }; } // Given normalized diyfp w, Grisu needs to find a (normalized) cached @@ -311,7 +310,7 @@ boundaries compute_boundaries(FloatType value) constexpr int kAlpha = -60; constexpr int kGamma = -32; -struct cached_power // c = f * 2^e ~= 10^k +struct cached_power // c = f * 2^e ~= 10^k { std::uint64_t f; int e; @@ -380,97 +379,35 @@ inline cached_power get_cached_power_for_binary_exponent(int e) constexpr int kCachedPowersMinDecExp = -300; constexpr int kCachedPowersDecStep = 8; - static constexpr std::array kCachedPowers = - { - { - { 0xAB70FE17C79AC6CA, -1060, -300 }, - { 0xFF77B1FCBEBCDC4F, -1034, -292 }, - { 0xBE5691EF416BD60C, -1007, -284 }, - { 0x8DD01FAD907FFC3C, -980, -276 }, - { 0xD3515C2831559A83, -954, -268 }, - { 0x9D71AC8FADA6C9B5, -927, -260 }, - { 0xEA9C227723EE8BCB, -901, -252 }, - { 0xAECC49914078536D, -874, -244 }, - { 0x823C12795DB6CE57, -847, -236 }, - { 0xC21094364DFB5637, -821, -228 }, - { 0x9096EA6F3848984F, -794, -220 }, - { 0xD77485CB25823AC7, -768, -212 }, - { 0xA086CFCD97BF97F4, -741, -204 }, - { 0xEF340A98172AACE5, -715, -196 }, - { 0xB23867FB2A35B28E, -688, -188 }, - { 0x84C8D4DFD2C63F3B, -661, -180 }, - { 0xC5DD44271AD3CDBA, -635, -172 }, - { 0x936B9FCEBB25C996, -608, -164 }, - { 0xDBAC6C247D62A584, -582, -156 }, - { 0xA3AB66580D5FDAF6, -555, -148 }, - { 0xF3E2F893DEC3F126, -529, -140 }, - { 0xB5B5ADA8AAFF80B8, -502, -132 }, - { 0x87625F056C7C4A8B, -475, -124 }, - { 0xC9BCFF6034C13053, -449, -116 }, - { 0x964E858C91BA2655, -422, -108 }, - { 0xDFF9772470297EBD, -396, -100 }, - { 0xA6DFBD9FB8E5B88F, -369, -92 }, - { 0xF8A95FCF88747D94, -343, -84 }, - { 0xB94470938FA89BCF, -316, -76 }, - { 0x8A08F0F8BF0F156B, -289, -68 }, - { 0xCDB02555653131B6, -263, -60 }, - { 0x993FE2C6D07B7FAC, -236, -52 }, - { 0xE45C10C42A2B3B06, -210, -44 }, - { 0xAA242499697392D3, -183, -36 }, - { 0xFD87B5F28300CA0E, -157, -28 }, - { 0xBCE5086492111AEB, -130, -20 }, - { 0x8CBCCC096F5088CC, -103, -12 }, - { 0xD1B71758E219652C, -77, -4 }, - { 0x9C40000000000000, -50, 4 }, - { 0xE8D4A51000000000, -24, 12 }, - { 0xAD78EBC5AC620000, 3, 20 }, - { 0x813F3978F8940984, 30, 28 }, - { 0xC097CE7BC90715B3, 56, 36 }, - { 0x8F7E32CE7BEA5C70, 83, 44 }, - { 0xD5D238A4ABE98068, 109, 52 }, - { 0x9F4F2726179A2245, 136, 60 }, - { 0xED63A231D4C4FB27, 162, 68 }, - { 0xB0DE65388CC8ADA8, 189, 76 }, - { 0x83C7088E1AAB65DB, 216, 84 }, - { 0xC45D1DF942711D9A, 242, 92 }, - { 0x924D692CA61BE758, 269, 100 }, - { 0xDA01EE641A708DEA, 295, 108 }, - { 0xA26DA3999AEF774A, 322, 116 }, - { 0xF209787BB47D6B85, 348, 124 }, - { 0xB454E4A179DD1877, 375, 132 }, - { 0x865B86925B9BC5C2, 402, 140 }, - { 0xC83553C5C8965D3D, 428, 148 }, - { 0x952AB45CFA97A0B3, 455, 156 }, - { 0xDE469FBD99A05FE3, 481, 164 }, - { 0xA59BC234DB398C25, 508, 172 }, - { 0xF6C69A72A3989F5C, 534, 180 }, - { 0xB7DCBF5354E9BECE, 561, 188 }, - { 0x88FCF317F22241E2, 588, 196 }, - { 0xCC20CE9BD35C78A5, 614, 204 }, - { 0x98165AF37B2153DF, 641, 212 }, - { 0xE2A0B5DC971F303A, 667, 220 }, - { 0xA8D9D1535CE3B396, 694, 228 }, - { 0xFB9B7CD9A4A7443C, 720, 236 }, - { 0xBB764C4CA7A44410, 747, 244 }, - { 0x8BAB8EEFB6409C1A, 774, 252 }, - { 0xD01FEF10A657842C, 800, 260 }, - { 0x9B10A4E5E9913129, 827, 268 }, - { 0xE7109BFBA19C0C9D, 853, 276 }, - { 0xAC2820D9623BF429, 880, 284 }, - { 0x80444B5E7AA7CF85, 907, 292 }, - { 0xBF21E44003ACDD2D, 933, 300 }, - { 0x8E679C2F5E44FF8F, 960, 308 }, - { 0xD433179D9C8CB841, 986, 316 }, - { 0x9E19DB92B4E31BA9, 1013, 324 }, - } - }; + static constexpr std::array kCachedPowers = { { + { 0xAB70FE17C79AC6CA, -1060, -300 }, { 0xFF77B1FCBEBCDC4F, -1034, -292 }, { 0xBE5691EF416BD60C, -1007, -284 }, { 0x8DD01FAD907FFC3C, -980, -276 }, + { 0xD3515C2831559A83, -954, -268 }, { 0x9D71AC8FADA6C9B5, -927, -260 }, { 0xEA9C227723EE8BCB, -901, -252 }, { 0xAECC49914078536D, -874, -244 }, + { 0x823C12795DB6CE57, -847, -236 }, { 0xC21094364DFB5637, -821, -228 }, { 0x9096EA6F3848984F, -794, -220 }, { 0xD77485CB25823AC7, -768, -212 }, + { 0xA086CFCD97BF97F4, -741, -204 }, { 0xEF340A98172AACE5, -715, -196 }, { 0xB23867FB2A35B28E, -688, -188 }, { 0x84C8D4DFD2C63F3B, -661, -180 }, + { 0xC5DD44271AD3CDBA, -635, -172 }, { 0x936B9FCEBB25C996, -608, -164 }, { 0xDBAC6C247D62A584, -582, -156 }, { 0xA3AB66580D5FDAF6, -555, -148 }, + { 0xF3E2F893DEC3F126, -529, -140 }, { 0xB5B5ADA8AAFF80B8, -502, -132 }, { 0x87625F056C7C4A8B, -475, -124 }, { 0xC9BCFF6034C13053, -449, -116 }, + { 0x964E858C91BA2655, -422, -108 }, { 0xDFF9772470297EBD, -396, -100 }, { 0xA6DFBD9FB8E5B88F, -369, -92 }, { 0xF8A95FCF88747D94, -343, -84 }, + { 0xB94470938FA89BCF, -316, -76 }, { 0x8A08F0F8BF0F156B, -289, -68 }, { 0xCDB02555653131B6, -263, -60 }, { 0x993FE2C6D07B7FAC, -236, -52 }, + { 0xE45C10C42A2B3B06, -210, -44 }, { 0xAA242499697392D3, -183, -36 }, { 0xFD87B5F28300CA0E, -157, -28 }, { 0xBCE5086492111AEB, -130, -20 }, + { 0x8CBCCC096F5088CC, -103, -12 }, { 0xD1B71758E219652C, -77, -4 }, { 0x9C40000000000000, -50, 4 }, { 0xE8D4A51000000000, -24, 12 }, + { 0xAD78EBC5AC620000, 3, 20 }, { 0x813F3978F8940984, 30, 28 }, { 0xC097CE7BC90715B3, 56, 36 }, { 0x8F7E32CE7BEA5C70, 83, 44 }, + { 0xD5D238A4ABE98068, 109, 52 }, { 0x9F4F2726179A2245, 136, 60 }, { 0xED63A231D4C4FB27, 162, 68 }, { 0xB0DE65388CC8ADA8, 189, 76 }, + { 0x83C7088E1AAB65DB, 216, 84 }, { 0xC45D1DF942711D9A, 242, 92 }, { 0x924D692CA61BE758, 269, 100 }, { 0xDA01EE641A708DEA, 295, 108 }, + { 0xA26DA3999AEF774A, 322, 116 }, { 0xF209787BB47D6B85, 348, 124 }, { 0xB454E4A179DD1877, 375, 132 }, { 0x865B86925B9BC5C2, 402, 140 }, + { 0xC83553C5C8965D3D, 428, 148 }, { 0x952AB45CFA97A0B3, 455, 156 }, { 0xDE469FBD99A05FE3, 481, 164 }, { 0xA59BC234DB398C25, 508, 172 }, + { 0xF6C69A72A3989F5C, 534, 180 }, { 0xB7DCBF5354E9BECE, 561, 188 }, { 0x88FCF317F22241E2, 588, 196 }, { 0xCC20CE9BD35C78A5, 614, 204 }, + { 0x98165AF37B2153DF, 641, 212 }, { 0xE2A0B5DC971F303A, 667, 220 }, { 0xA8D9D1535CE3B396, 694, 228 }, { 0xFB9B7CD9A4A7443C, 720, 236 }, + { 0xBB764C4CA7A44410, 747, 244 }, { 0x8BAB8EEFB6409C1A, 774, 252 }, { 0xD01FEF10A657842C, 800, 260 }, { 0x9B10A4E5E9913129, 827, 268 }, + { 0xE7109BFBA19C0C9D, 853, 276 }, { 0xAC2820D9623BF429, 880, 284 }, { 0x80444B5E7AA7CF85, 907, 292 }, { 0xBF21E44003ACDD2D, 933, 300 }, + { 0x8E679C2F5E44FF8F, 960, 308 }, { 0xD433179D9C8CB841, 986, 316 }, { 0x9E19DB92B4E31BA9, 1013, 324 }, + } }; // This computation gives exactly the same results for k as // k = ceil((kAlpha - e - 1) * 0.30102999566398114) // for |e| <= 1500, but doesn't require floating-point operations. // NB: log_10(2) ~= 78913 / 2^18 JSON_ASSERT(e >= -1500); - JSON_ASSERT(e <= 1500); + JSON_ASSERT(e <= 1500); const int f = kAlpha - e - 1; const int k = (f * 78913) / (1 << 18) + static_cast(f > 0); @@ -501,50 +438,49 @@ inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10) if (n >= 100000000) { pow10 = 100000000; - return 9; + return 9; } if (n >= 10000000) { pow10 = 10000000; - return 8; + return 8; } if (n >= 1000000) { pow10 = 1000000; - return 7; + return 7; } if (n >= 100000) { pow10 = 100000; - return 6; + return 6; } if (n >= 10000) { pow10 = 10000; - return 5; + return 5; } if (n >= 1000) { pow10 = 1000; - return 4; + return 4; } if (n >= 100) { pow10 = 100; - return 3; + return 3; } if (n >= 10) { pow10 = 10; - return 2; + return 2; } pow10 = 1; return 1; } -inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta, - std::uint64_t rest, std::uint64_t ten_k) +inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k) { JSON_ASSERT(len >= 1); JSON_ASSERT(dist <= delta); @@ -570,9 +506,7 @@ inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t d // The tests are written in this order to avoid overflow in unsigned // integer arithmetic. - while (rest < dist - && delta - rest >= ten_k - && (rest + ten_k < dist || dist - rest > rest + ten_k - dist)) + while (rest < dist && delta - rest >= ten_k && (rest + ten_k < dist || dist - rest > rest + ten_k - dist)) { JSON_ASSERT(buf[len - 1] != '0'); buf[len - 1]--; @@ -584,8 +518,7 @@ inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t d Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+. M- and M+ must be normalized and share the same exponent -60 <= e <= -32. */ -inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, - diyfp M_minus, diyfp w, diyfp M_plus) +inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus) { static_assert(kAlpha >= -60, "internal error"); static_assert(kGamma <= -32, "internal error"); @@ -605,8 +538,8 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, JSON_ASSERT(M_plus.e >= kAlpha); JSON_ASSERT(M_plus.e <= kGamma); - std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e) - std::uint64_t dist = diyfp::sub(M_plus, w ).f; // (significand of (M+ - w ), implicit exponent is e) + std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e) + std::uint64_t dist = diyfp::sub(M_plus, w).f; // (significand of (M+ - w ), implicit exponent is e) // Split M+ = f * 2^e into two parts p1 and p2 (note: e < 0): // @@ -615,10 +548,10 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, // = ((p1 ) * 2^-e + (p2 )) * 2^e // = p1 + p2 * 2^e - const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e); + const diyfp one(std::uint64_t{ 1 } << -M_plus.e, M_plus.e); - auto p1 = static_cast(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.) - std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e + auto p1 = static_cast(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.) + std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e // 1) // @@ -661,7 +594,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, // = (buffer * 10 + d) * 10^(n-1) + (r + p2 * 2^e) // JSON_ASSERT(d <= 9); - buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d + buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d // // M+ = buffer * 10^(n-1) + (r + p2 * 2^e) // @@ -680,7 +613,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, // Note: // Since rest and delta share the same exponent e, it suffices to // compare the significands. - const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2; + const std::uint64_t rest = (std::uint64_t{ p1 } << -one.e) + p2; if (rest <= delta) { // V = buffer * 10^n, with M- <= V <= M+. @@ -696,7 +629,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, // // 10^n = (10^n * 2^-e) * 2^e = ulp * 2^e // - const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e; + const std::uint64_t ten_n = std::uint64_t{ pow10 } << -one.e; grisu2_round(buffer, length, dist, delta, rest, ten_n); return; @@ -760,15 +693,15 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, // JSON_ASSERT(p2 <= (std::numeric_limits::max)() / 10); p2 *= 10; - const std::uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e - const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e + const std::uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e + const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e // // M+ = buffer * 10^-m + 10^-m * (1/10 * (d * 2^-e + r) * 2^e // = buffer * 10^-m + 10^-m * (1/10 * (d + r * 2^e)) // = (buffer * 10 + d) * 10^(-m-1) + 10^(-m-1) * r * 2^e // JSON_ASSERT(d <= 9); - buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d + buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d // // M+ = buffer * 10^(-m-1) + 10^(-m-1) * r * 2^e // @@ -784,7 +717,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, // p2 * 2^e <= 10^m * delta * 2^e // p2 <= 10^m * delta delta *= 10; - dist *= 10; + dist *= 10; if (p2 <= delta) { break; @@ -825,8 +758,7 @@ len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ JSON_HEDLEY_NON_NULL(1) -inline void grisu2(char* buf, int& len, int& decimal_exponent, - diyfp m_minus, diyfp v, diyfp m_plus) +inline void grisu2(char* buf, int& len, int& decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus) { JSON_ASSERT(m_plus.e == m_minus.e); JSON_ASSERT(m_plus.e == v.e); @@ -842,12 +774,12 @@ inline void grisu2(char* buf, int& len, int& decimal_exponent, const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e); - const diyfp c_minus_k(cached.f, cached.e); // = c ~= 10^-k + const diyfp c_minus_k(cached.f, cached.e); // = c ~= 10^-k // The exponent of the products is = v.e + c_minus_k.e + q and is in the range [alpha,gamma] - const diyfp w = diyfp::mul(v, c_minus_k); + const diyfp w = diyfp::mul(v, c_minus_k); const diyfp w_minus = diyfp::mul(m_minus, c_minus_k); - const diyfp w_plus = diyfp::mul(m_plus, c_minus_k); + const diyfp w_plus = diyfp::mul(m_plus, c_minus_k); // ----(---+---)---------------(---+---)---------------(---+---)---- // w- w w+ @@ -871,9 +803,9 @@ inline void grisu2(char* buf, int& len, int& decimal_exponent, // Note that this does not mean that Grisu2 always generates the shortest // possible number in the interval (m-, m+). const diyfp M_minus(w_minus.f + 1, w_minus.e); - const diyfp M_plus (w_plus.f - 1, w_plus.e ); + const diyfp M_plus(w_plus.f - 1, w_plus.e); - decimal_exponent = -cached.k; // = -(-k) = k + decimal_exponent = -cached.k; // = -(-k) = k grisu2_digit_gen(buf, len, decimal_exponent, M_minus, w, M_plus); } @@ -887,8 +819,7 @@ template JSON_HEDLEY_NON_NULL(1) void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) { - static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, - "internal error: not enough precision"); + static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, "internal error: not enough precision"); JSON_ASSERT(std::isfinite(value)); JSON_ASSERT(value > 0); @@ -909,7 +840,7 @@ void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) // NB: If the neighbors are computed for single-precision numbers, there is a single float // (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision // value is off by 1 ulp. -#if 0 // NOLINT(readability-avoid-unconditional-preprocessor-if) +#if 0 // NOLINT(readability-avoid-unconditional-preprocessor-if) const boundaries w = compute_boundaries(static_cast(value)); #else const boundaries w = compute_boundaries(value); @@ -928,7 +859,7 @@ JSON_HEDLEY_RETURNS_NON_NULL inline char* append_exponent(char* buf, int e) { JSON_ASSERT(e > -1000); - JSON_ASSERT(e < 1000); + JSON_ASSERT(e < 1000); if (e < 0) { @@ -977,8 +908,7 @@ notation. Otherwise it will be printed in exponential notation. */ JSON_HEDLEY_NON_NULL(1) JSON_HEDLEY_RETURNS_NON_NULL -inline char* format_buffer(char* buf, int len, int decimal_exponent, - int min_exp, int max_exp) +inline char* format_buffer(char* buf, int len, int decimal_exponent, int min_exp, int max_exp) { JSON_ASSERT(min_exp < 0); JSON_ASSERT(max_exp > 0); @@ -1061,10 +991,9 @@ format. Returns an iterator pointing past-the-end of the decimal representation. */ template JSON_HEDLEY_NON_NULL(1, 2) -JSON_HEDLEY_RETURNS_NON_NULL -char* to_chars(char* first, const char* last, FloatType value) +JSON_HEDLEY_RETURNS_NON_NULL char* to_chars(char* first, const char* last, FloatType value) { - static_cast(last); // maybe unused - fix warning + static_cast(last); // maybe unused - fix warning JSON_ASSERT(std::isfinite(value)); // Use signbit(value) instead of (value < 0) since signbit works for -0. @@ -1075,10 +1004,10 @@ char* to_chars(char* first, const char* last, FloatType value) } #ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" #endif - if (value == 0) // +-0 + if (value == 0) // +-0 { *first++ = '0'; // Make it look like a floating-point number (#362, #378) @@ -1087,7 +1016,7 @@ char* to_chars(char* first, const char* last, FloatType value) return first; } #ifdef __GNUC__ -#pragma GCC diagnostic pop + #pragma GCC diagnostic pop #endif JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index e39b7797dd..f69205eaf5 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -8,14 +8,14 @@ #pragma once -#include // copy -#include // begin, end -#include // string -#include // tuple, get -#include // is_same, is_constructible, is_floating_point, is_enum, underlying_type -#include // move, forward, declval, pair -#include // valarray -#include // vector +#include // copy +#include // begin, end +#include // string +#include // tuple, get +#include // is_same, is_constructible, is_floating_point, is_enum, underlying_type +#include // move, forward, declval, pair +#include // valarray +#include // vector #include #include @@ -39,7 +39,8 @@ namespace detail * https://github.com/nlohmann/json/issues/2865 for more information. */ -template struct external_constructor; +template +struct external_constructor; template<> struct external_constructor @@ -75,9 +76,9 @@ struct external_constructor j.assert_invariant(); } - template < typename BasicJsonType, typename CompatibleStringType, - enable_if_t < !std::is_same::value, - int > = 0 > + template::value, int> = 0> static void construct(BasicJsonType& j, const CompatibleStringType& str) { j.m_data.m_value.destroy(j.m_data.m_type); @@ -171,9 +172,9 @@ struct external_constructor j.assert_invariant(); } - template < typename BasicJsonType, typename CompatibleArrayType, - enable_if_t < !std::is_same::value, - int > = 0 > + template::value, int> = 0> static void construct(BasicJsonType& j, const CompatibleArrayType& arr) { using std::begin; @@ -201,8 +202,7 @@ struct external_constructor j.assert_invariant(); } - template::value, int> = 0> + template::value, int> = 0> static void construct(BasicJsonType& j, const std::valarray& arr) { j.m_data.m_value.destroy(j.m_data.m_type); @@ -241,8 +241,9 @@ struct external_constructor j.assert_invariant(); } - template < typename BasicJsonType, typename CompatibleObjectType, - enable_if_t < !std::is_same::value, int > = 0 > + template::value, int> = 0> static void construct(BasicJsonType& j, const CompatibleObjectType& obj) { using std::begin; @@ -260,27 +261,27 @@ struct external_constructor // to_json // ///////////// -template::value, int> = 0> +template::value, int> = 0> inline void to_json(BasicJsonType& j, T b) noexcept { external_constructor::construct(j, b); } -template < typename BasicJsonType, typename BoolRef, - enable_if_t < - ((std::is_same::reference, BoolRef>::value - && !std::is_same ::reference, typename BasicJsonType::boolean_t&>::value) - || (std::is_same::const_reference, BoolRef>::value - && !std::is_same ::const_reference>, - typename BasicJsonType::boolean_t >::value)) - && std::is_convertible::value, int > = 0 > +template::reference, BoolRef>::value && + !std::is_same::reference, typename BasicJsonType::boolean_t&>::value) || + (std::is_same::const_reference, BoolRef>::value && + !std::is_same::const_reference>, typename BasicJsonType::boolean_t>::value)) && + std::is_convertible::value, + int> = 0> inline void to_json(BasicJsonType& j, const BoolRef& b) noexcept { external_constructor::construct(j, static_cast(b)); } -template::value, int> = 0> inline void to_json(BasicJsonType& j, const CompatibleString& s) { @@ -293,21 +294,22 @@ inline void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s) external_constructor::construct(j, std::move(s)); } -template::value, int> = 0> +template::value, int> = 0> inline void to_json(BasicJsonType& j, FloatType val) noexcept { external_constructor::construct(j, static_cast(val)); } -template::value, int> = 0> inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept { external_constructor::construct(j, static_cast(val)); } -template::value, int> = 0> inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept { @@ -315,8 +317,7 @@ inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept } #if !JSON_DISABLE_ENUM_SERIALIZATION -template::value, int> = 0> +template::value, int> = 0> inline void to_json(BasicJsonType& j, EnumType e) noexcept { using underlying_type = typename std::underlying_type::type; @@ -330,14 +331,13 @@ inline void to_json(BasicJsonType& j, const std::vector& e) external_constructor::construct(j, e); } -template < typename BasicJsonType, typename CompatibleArrayType, - enable_if_t < is_compatible_array_type::value&& - !is_compatible_object_type::value&& - !is_compatible_string_type::value&& - !std::is_same::value&& - !is_basic_json::value, - int > = 0 > +template< + typename BasicJsonType, + typename CompatibleArrayType, + enable_if_t::value && !is_compatible_object_type::value && + !is_compatible_string_type::value && + !std::is_same::value && !is_basic_json::value, + int> = 0> inline void to_json(BasicJsonType& j, const CompatibleArrayType& arr) { external_constructor::construct(j, arr); @@ -349,8 +349,7 @@ inline void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bi external_constructor::construct(j, bin); } -template::value, int> = 0> +template::value, int> = 0> inline void to_json(BasicJsonType& j, const std::valarray& arr) { external_constructor::construct(j, std::move(arr)); @@ -362,8 +361,9 @@ inline void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) external_constructor::construct(j, std::move(arr)); } -template < typename BasicJsonType, typename CompatibleObjectType, - enable_if_t < is_compatible_object_type::value&& !is_basic_json::value, int > = 0 > +template::value && !is_basic_json::value, int> = 0> inline void to_json(BasicJsonType& j, const CompatibleObjectType& obj) { external_constructor::construct(j, obj); @@ -375,28 +375,31 @@ inline void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) external_constructor::construct(j, std::move(obj)); } -template < - typename BasicJsonType, typename T, std::size_t N, - enable_if_t < !std::is_constructible::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - int > = 0 > -inline void to_json(BasicJsonType& j, const T(&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) +template::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) + int> = 0> +inline void to_json(BasicJsonType& j, const T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) { external_constructor::construct(j, arr); } -template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible::value&& std::is_constructible::value, int > = 0 > +template::value && std::is_constructible::value, int> = 0> inline void to_json(BasicJsonType& j, const std::pair& p) { j = { p.first, p.second }; } // for https://github.com/nlohmann/json/pull/1134 -template>::value, int> = 0> +template>::value, int> = 0> inline void to_json(BasicJsonType& j, const T& b) { - j = { {b.key(), b.value()} }; + j = { { b.key(), b.value() } }; } template @@ -405,10 +408,10 @@ inline void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence< j = { std::get(t)... }; } -template::value, int > = 0> +template::value, int> = 0> inline void to_json(BasicJsonType& j, const T& t) { - to_json_tuple_impl(j, t, make_index_sequence::value> {}); + to_json_tuple_impl(j, t, make_index_sequence::value>{}); } #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM @@ -422,8 +425,7 @@ inline void to_json(BasicJsonType& j, const std_fs::path& p) struct to_json_fn { template - auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward(val)))) - -> decltype(to_json(j, std::forward(val)), void()) + auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward(val)))) -> decltype(to_json(j, std::forward(val)), void()) { return to_json(j, std::forward(val)); } @@ -434,10 +436,10 @@ struct to_json_fn /// namespace to hold default `to_json` function /// to see why this is required: /// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html -namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) +namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) { #endif -JSON_INLINE_VARIABLE constexpr const auto& to_json = // NOLINT(misc-definitions-in-headers) +JSON_INLINE_VARIABLE constexpr const auto& to_json = // NOLINT(misc-definitions-in-headers) detail::static_const::value; #ifndef JSON_HAS_CPP_17 } // namespace diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp index 5974d7be2b..98e415325e 100644 --- a/include/nlohmann/detail/exceptions.hpp +++ b/include/nlohmann/detail/exceptions.hpp @@ -8,22 +8,22 @@ #pragma once -#include // nullptr_t -#include // exception +#include // nullptr_t +#include // exception #if JSON_DIAGNOSTICS - #include // accumulate + #include // accumulate #endif -#include // runtime_error -#include // to_string -#include // vector +#include // runtime_error +#include // to_string +#include // vector -#include -#include #include #include #include #include #include +#include +#include NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail @@ -45,11 +45,14 @@ class exception : public std::exception } /// the id of the exception - const int id; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) + const int id; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) protected: JSON_HEDLEY_NON_NULL(3) - exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} // NOLINT(bugprone-throw-keyword-missing) + exception(int id_, const char* what_arg) + : id(id_) + , m(what_arg) // NOLINT(bugprone-throw-keyword-missing) + {} static std::string name(const std::string& ename, int id_) { @@ -96,16 +99,16 @@ class exception : public std::exception break; } - case value_t::null: // LCOV_EXCL_LINE - case value_t::string: // LCOV_EXCL_LINE - case value_t::boolean: // LCOV_EXCL_LINE - case value_t::number_integer: // LCOV_EXCL_LINE - case value_t::number_unsigned: // LCOV_EXCL_LINE - case value_t::number_float: // LCOV_EXCL_LINE - case value_t::binary: // LCOV_EXCL_LINE - case value_t::discarded: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - break; // LCOV_EXCL_LINE + case value_t::null: // LCOV_EXCL_LINE + case value_t::string: // LCOV_EXCL_LINE + case value_t::boolean: // LCOV_EXCL_LINE + case value_t::number_integer: // LCOV_EXCL_LINE + case value_t::number_unsigned: // LCOV_EXCL_LINE + case value_t::number_float: // LCOV_EXCL_LINE + case value_t::binary: // LCOV_EXCL_LINE + case value_t::discarded: // LCOV_EXCL_LINE + default: // LCOV_EXCL_LINE + break; // LCOV_EXCL_LINE } } @@ -114,9 +117,7 @@ class exception : public std::exception return ""; } - auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{}, - [](const std::string & a, const std::string & b) - { + auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{}, [](const std::string& a, const std::string& b) { return concat(a, '/', detail::escape(b)); }); return concat('(', str, ") "); @@ -148,18 +149,20 @@ class parse_error : public exception template::value, int> = 0> static parse_error create(int id_, const position_t& pos, const std::string& what_arg, BasicJsonContext context) { - const std::string w = concat(exception::name("parse_error", id_), "parse error", - position_string(pos), ": ", exception::diagnostics(context), what_arg); - return {id_, pos.chars_read_total, w.c_str()}; + const std::string w = concat(exception::name("parse_error", id_), "parse error", position_string(pos), ": ", exception::diagnostics(context), what_arg); + return { id_, pos.chars_read_total, w.c_str() }; } template::value, int> = 0> static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, BasicJsonContext context) { - const std::string w = concat(exception::name("parse_error", id_), "parse error", + const std::string w = concat(exception::name("parse_error", id_), + "parse error", (byte_ != 0 ? (concat(" at byte ", std::to_string(byte_))) : ""), - ": ", exception::diagnostics(context), what_arg); - return {id_, byte_, w.c_str()}; + ": ", + exception::diagnostics(context), + what_arg); + return { id_, byte_, w.c_str() }; } /*! @@ -175,12 +178,13 @@ class parse_error : public exception private: parse_error(int id_, std::size_t byte_, const char* what_arg) - : exception(id_, what_arg), byte(byte_) {} + : exception(id_, what_arg) + , byte(byte_) + {} static std::string position_string(const position_t& pos) { - return concat(" at line ", std::to_string(pos.lines_read + 1), - ", column ", std::to_string(pos.chars_read_current_line)); + return concat(" at line ", std::to_string(pos.lines_read + 1), ", column ", std::to_string(pos.chars_read_current_line)); } }; @@ -193,13 +197,14 @@ class invalid_iterator : public exception static invalid_iterator create(int id_, const std::string& what_arg, BasicJsonContext context) { const std::string w = concat(exception::name("invalid_iterator", id_), exception::diagnostics(context), what_arg); - return {id_, w.c_str()}; + return { id_, w.c_str() }; } private: JSON_HEDLEY_NON_NULL(3) invalid_iterator(int id_, const char* what_arg) - : exception(id_, what_arg) {} + : exception(id_, what_arg) + {} }; /// @brief exception indicating executing a member function with a wrong type @@ -211,12 +216,14 @@ class type_error : public exception static type_error create(int id_, const std::string& what_arg, BasicJsonContext context) { const std::string w = concat(exception::name("type_error", id_), exception::diagnostics(context), what_arg); - return {id_, w.c_str()}; + return { id_, w.c_str() }; } private: JSON_HEDLEY_NON_NULL(3) - type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} + type_error(int id_, const char* what_arg) + : exception(id_, what_arg) + {} }; /// @brief exception indicating access out of the defined range @@ -228,12 +235,14 @@ class out_of_range : public exception static out_of_range create(int id_, const std::string& what_arg, BasicJsonContext context) { const std::string w = concat(exception::name("out_of_range", id_), exception::diagnostics(context), what_arg); - return {id_, w.c_str()}; + return { id_, w.c_str() }; } private: JSON_HEDLEY_NON_NULL(3) - out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} + out_of_range(int id_, const char* what_arg) + : exception(id_, what_arg) + {} }; /// @brief exception indicating other library errors @@ -245,12 +254,14 @@ class other_error : public exception static other_error create(int id_, const std::string& what_arg, BasicJsonContext context) { const std::string w = concat(exception::name("other_error", id_), exception::diagnostics(context), what_arg); - return {id_, w.c_str()}; + return { id_, w.c_str() }; } private: JSON_HEDLEY_NON_NULL(3) - other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} + other_error(int id_, const char* what_arg) + : exception(id_, what_arg) + {} }; } // namespace detail diff --git a/include/nlohmann/detail/hash.hpp b/include/nlohmann/detail/hash.hpp index 4464e8e67b..2d405110b0 100644 --- a/include/nlohmann/detail/hash.hpp +++ b/include/nlohmann/detail/hash.hpp @@ -8,9 +8,9 @@ #pragma once -#include // uint8_t -#include // size_t -#include // hash +#include // size_t +#include // uint8_t +#include // hash #include #include @@ -59,7 +59,7 @@ std::size_t hash(const BasicJsonType& j) auto seed = combine(type, j.size()); for (const auto& element : j.items()) { - const auto h = std::hash {}(element.key()); + const auto h = std::hash{}(element.key()); seed = combine(seed, h); seed = combine(seed, hash(element.value())); } @@ -78,50 +78,50 @@ std::size_t hash(const BasicJsonType& j) case BasicJsonType::value_t::string: { - const auto h = std::hash {}(j.template get_ref()); + const auto h = std::hash{}(j.template get_ref()); return combine(type, h); } case BasicJsonType::value_t::boolean: { - const auto h = std::hash {}(j.template get()); + const auto h = std::hash{}(j.template get()); return combine(type, h); } case BasicJsonType::value_t::number_integer: { - const auto h = std::hash {}(j.template get()); + const auto h = std::hash{}(j.template get()); return combine(type, h); } case BasicJsonType::value_t::number_unsigned: { - const auto h = std::hash {}(j.template get()); + const auto h = std::hash{}(j.template get()); return combine(type, h); } case BasicJsonType::value_t::number_float: { - const auto h = std::hash {}(j.template get()); + const auto h = std::hash{}(j.template get()); return combine(type, h); } case BasicJsonType::value_t::binary: { auto seed = combine(type, j.get_binary().size()); - const auto h = std::hash {}(j.get_binary().has_subtype()); + const auto h = std::hash{}(j.get_binary().has_subtype()); seed = combine(seed, h); seed = combine(seed, static_cast(j.get_binary().subtype())); for (const auto byte : j.get_binary()) { - seed = combine(seed, std::hash {}(byte)); + seed = combine(seed, std::hash{}(byte)); } return seed; } - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - return 0; // LCOV_EXCL_LINE + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE + return 0; // LCOV_EXCL_LINE } } diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index a6e100e761..91ac83d494 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -8,18 +8,18 @@ #pragma once -#include // generate_n -#include // array -#include // ldexp -#include // size_t -#include // uint8_t, uint16_t, uint32_t, uint64_t -#include // snprintf -#include // memcpy -#include // back_inserter -#include // numeric_limits -#include // char_traits, string -#include // make_pair, move -#include // vector +#include // generate_n +#include // array +#include // ldexp +#include // size_t +#include // uint8_t, uint16_t, uint32_t, uint64_t +#include // snprintf +#include // memcpy +#include // back_inserter +#include // numeric_limits +#include // char_traits, string +#include // make_pair, move +#include // vector #include #include @@ -80,16 +80,18 @@ class binary_reader @param[in] adapter input adapter to read from */ - explicit binary_reader(InputAdapterType&& adapter, const input_format_t format = input_format_t::json) noexcept : ia(std::move(adapter)), input_format(format) + explicit binary_reader(InputAdapterType&& adapter, const input_format_t format = input_format_t::json) noexcept + : ia(std::move(adapter)) + , input_format(format) { - (void)detail::is_sax_static_asserts {}; + (void)detail::is_sax_static_asserts{}; } // make class move-only binary_reader(const binary_reader&) = delete; - binary_reader(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) + binary_reader(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) binary_reader& operator=(const binary_reader&) = delete; - binary_reader& operator=(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) + binary_reader& operator=(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) ~binary_reader() = default; /*! @@ -101,10 +103,7 @@ class binary_reader @return whether parsing was successful */ JSON_HEDLEY_NON_NULL(3) - bool sax_parse(const input_format_t format, - json_sax_t* sax_, - const bool strict = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + bool sax_parse(const input_format_t format, json_sax_t* sax_, const bool strict = true, const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) { sax = sax_; bool result = false; @@ -128,9 +127,9 @@ class binary_reader result = parse_ubjson_internal(); break; - case input_format_t::json: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE + case input_format_t::json: // LCOV_EXCL_LINE + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE } // strict mode: next byte must be EOF @@ -147,8 +146,13 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(current != char_traits::eof())) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read, - exception_message(input_format, concat("expected end of input; last byte: 0x", get_token_string()), "value"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + parse_error::create(110, + chars_read, + exception_message(input_format, concat("expected end of input; last byte: 0x", get_token_string()), "value"), + nullptr)); } } @@ -174,7 +178,7 @@ class binary_reader return false; } - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/false))) + if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/ false))) { return false; } @@ -224,8 +228,13 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(len < 1)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format_t::bson, concat("string length must be at least 1, is ", std::to_string(len)), "string"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format_t::bson, concat("string length must be at least 1, is ", std::to_string(len)), "string"), + nullptr)); } return get_string(input_format_t::bson, len - static_cast(1), result) && get() != char_traits::eof(); @@ -246,8 +255,13 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(len < 0)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format_t::bson, concat("byte array length cannot be negative, is ", std::to_string(len)), "binary"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format_t::bson, concat("byte array length cannot be negative, is ", std::to_string(len)), "binary"), + nullptr)); } // All BSON binary values have a subtype @@ -268,69 +282,72 @@ class binary_reader Unsupported BSON record type 0x... @return whether a valid BSON-object/array was passed to the SAX parser */ - bool parse_bson_element_internal(const char_int_type element_type, - const std::size_t element_type_parse_position) + bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position) { switch (element_type) { - case 0x01: // double + case 0x01: // double { double number{}; return get_number(input_format_t::bson, number) && sax->number_float(static_cast(number), ""); } - case 0x02: // string + case 0x02: // string { std::int32_t len{}; string_t value; return get_number(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value); } - case 0x03: // object + case 0x03: // object { return parse_bson_internal(); } - case 0x04: // array + case 0x04: // array { return parse_bson_array(); } - case 0x05: // binary + case 0x05: // binary { std::int32_t len{}; binary_t value; return get_number(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value); } - case 0x08: // boolean + case 0x08: // boolean { return sax->boolean(get() != 0); } - case 0x0A: // null + case 0x0A: // null { return sax->null(); } - case 0x10: // int32 + case 0x10: // int32 { std::int32_t value{}; return get_number(input_format_t::bson, value) && sax->number_integer(value); } - case 0x12: // int64 + case 0x12: // int64 { std::int64_t value{}; return get_number(input_format_t::bson, value) && sax->number_integer(value); } - default: // anything else not supported (yet) + default: // anything else not supported (yet) { - std::array cr{{}}; - static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - const std::string cr_str{cr.data()}; - return sax->parse_error(element_type_parse_position, cr_str, + std::array cr{ {} }; + static_cast((std::snprintf)(cr.data(), // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + cr.size(), + "%.2hhX", + static_cast(element_type))); + const std::string cr_str{ cr.data() }; + return sax->parse_error(element_type_parse_position, + cr_str, parse_error::create(114, element_type_parse_position, concat("Unsupported BSON record type 0x", cr_str), nullptr)); } } @@ -396,7 +413,7 @@ class binary_reader return false; } - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/true))) + if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/ true))) { return false; } @@ -416,8 +433,7 @@ class binary_reader @return whether a valid CBOR value was passed to the SAX parser */ - bool parse_cbor_internal(const bool get_char, - const cbor_tag_handler_t tag_handler) + bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler) { switch (get_char ? get() : current) { @@ -452,25 +468,25 @@ class binary_reader case 0x17: return sax->number_unsigned(static_cast(current)); - case 0x18: // Unsigned integer (one-byte uint8_t follows) + case 0x18: // Unsigned integer (one-byte uint8_t follows) { std::uint8_t number{}; return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); } - case 0x19: // Unsigned integer (two-byte uint16_t follows) + case 0x19: // Unsigned integer (two-byte uint16_t follows) { std::uint16_t number{}; return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); } - case 0x1A: // Unsigned integer (four-byte uint32_t follows) + case 0x1A: // Unsigned integer (four-byte uint32_t follows) { std::uint32_t number{}; return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); } - case 0x1B: // Unsigned integer (eight-byte uint64_t follows) + case 0x1B: // Unsigned integer (eight-byte uint64_t follows) { std::uint64_t number{}; return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); @@ -503,29 +519,29 @@ class binary_reader case 0x37: return sax->number_integer(static_cast(0x20 - 1 - current)); - case 0x38: // Negative integer (one-byte uint8_t follows) + case 0x38: // Negative integer (one-byte uint8_t follows) { std::uint8_t number{}; return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); } - case 0x39: // Negative integer -1-n (two-byte uint16_t follows) + case 0x39: // Negative integer -1-n (two-byte uint16_t follows) { std::uint16_t number{}; return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); } - case 0x3A: // Negative integer -1-n (four-byte uint32_t follows) + case 0x3A: // Negative integer -1-n (four-byte uint32_t follows) { std::uint32_t number{}; return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); } - case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) + case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) { std::uint64_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - - static_cast(number)); + return get_number(input_format_t::cbor, number) && + sax->number_integer(static_cast(-1) - static_cast(number)); } // Binary data (0x00..0x17 bytes follow) @@ -553,11 +569,11 @@ class binary_reader case 0x55: case 0x56: case 0x57: - case 0x58: // Binary data (one-byte uint8_t for n follows) - case 0x59: // Binary data (two-byte uint16_t for n follow) - case 0x5A: // Binary data (four-byte uint32_t for n follow) - case 0x5B: // Binary data (eight-byte uint64_t for n follow) - case 0x5F: // Binary data (indefinite length) + case 0x58: // Binary data (one-byte uint8_t for n follows) + case 0x59: // Binary data (two-byte uint16_t for n follow) + case 0x5A: // Binary data (four-byte uint32_t for n follow) + case 0x5B: // Binary data (eight-byte uint64_t for n follow) + case 0x5F: // Binary data (indefinite length) { binary_t b; return get_cbor_binary(b) && sax->binary(b); @@ -588,11 +604,11 @@ class binary_reader case 0x75: case 0x76: case 0x77: - case 0x78: // UTF-8 string (one-byte uint8_t for n follows) - case 0x79: // UTF-8 string (two-byte uint16_t for n follow) - case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) - case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) - case 0x7F: // UTF-8 string (indefinite length) + case 0x78: // UTF-8 string (one-byte uint8_t for n follows) + case 0x79: // UTF-8 string (two-byte uint16_t for n follow) + case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) + case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) + case 0x7F: // UTF-8 string (indefinite length) { string_t s; return get_cbor_string(s) && sax->string(s); @@ -623,34 +639,33 @@ class binary_reader case 0x95: case 0x96: case 0x97: - return get_cbor_array( - conditional_static_cast(static_cast(current) & 0x1Fu), tag_handler); + return get_cbor_array(conditional_static_cast(static_cast(current) & 0x1Fu), tag_handler); - case 0x98: // array (one-byte uint8_t for n follows) + case 0x98: // array (one-byte uint8_t for n follows) { std::uint8_t len{}; return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); } - case 0x99: // array (two-byte uint16_t for n follow) + case 0x99: // array (two-byte uint16_t for n follow) { std::uint16_t len{}; return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); } - case 0x9A: // array (four-byte uint32_t for n follow) + case 0x9A: // array (four-byte uint32_t for n follow) { std::uint32_t len{}; return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast(len), tag_handler); } - case 0x9B: // array (eight-byte uint64_t for n follow) + case 0x9B: // array (eight-byte uint64_t for n follow) { std::uint64_t len{}; return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast(len), tag_handler); } - case 0x9F: // array (indefinite length) + case 0x9F: // array (indefinite length) return get_cbor_array(static_cast(-1), tag_handler); // map (0x00..0x17 pairs of data items follow) @@ -680,34 +695,34 @@ class binary_reader case 0xB7: return get_cbor_object(conditional_static_cast(static_cast(current) & 0x1Fu), tag_handler); - case 0xB8: // map (one-byte uint8_t for n follows) + case 0xB8: // map (one-byte uint8_t for n follows) { std::uint8_t len{}; return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); } - case 0xB9: // map (two-byte uint16_t for n follow) + case 0xB9: // map (two-byte uint16_t for n follow) { std::uint16_t len{}; return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); } - case 0xBA: // map (four-byte uint32_t for n follow) + case 0xBA: // map (four-byte uint32_t for n follow) { std::uint32_t len{}; return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast(len), tag_handler); } - case 0xBB: // map (eight-byte uint64_t for n follow) + case 0xBB: // map (eight-byte uint64_t for n follow) { std::uint64_t len{}; return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast(len), tag_handler); } - case 0xBF: // map (indefinite length) + case 0xBF: // map (indefinite length) return get_cbor_object(static_cast(-1), tag_handler); - case 0xC6: // tagged item + case 0xC6: // tagged item case 0xC7: case 0xC8: case 0xC9: @@ -722,18 +737,22 @@ class binary_reader case 0xD2: case 0xD3: case 0xD4: - case 0xD8: // tagged item (1 bytes follow) - case 0xD9: // tagged item (2 bytes follow) - case 0xDA: // tagged item (4 bytes follow) - case 0xDB: // tagged item (8 bytes follow) + case 0xD8: // tagged item (1 bytes follow) + case 0xD9: // tagged item (2 bytes follow) + case 0xDA: // tagged item (4 bytes follow) + case 0xDB: // tagged item (8 bytes follow) { switch (tag_handler) { case cbor_tag_handler_t::error: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); + return sax->parse_error(chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), + nullptr)); } case cbor_tag_handler_t::ignore: @@ -813,21 +832,21 @@ class binary_reader } default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE + JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE return false; // LCOV_EXCL_LINE } } - case 0xF4: // false + case 0xF4: // false return sax->boolean(false); - case 0xF5: // true + case 0xF5: // true return sax->boolean(true); - case 0xF6: // null + case 0xF6: // null return sax->null(); - case 0xF9: // Half-Precision Float (two-byte IEEE 754) + case 0xF9: // Half-Precision Float (two-byte IEEE 754) { const auto byte1_raw = get(); if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) @@ -852,46 +871,43 @@ class binary_reader // half-precision floating-point numbers in the C language // is shown in Fig. 3. const auto half = static_cast((byte1 << 8u) + byte2); - const double val = [&half] - { + const double val = [&half] { const int exp = (half >> 10u) & 0x1Fu; const unsigned int mant = half & 0x3FFu; - JSON_ASSERT(0 <= exp&& exp <= 32); + JSON_ASSERT(0 <= exp && exp <= 32); JSON_ASSERT(mant <= 1024); switch (exp) { case 0: return std::ldexp(mant, -24); case 31: - return (mant == 0) - ? std::numeric_limits::infinity() - : std::numeric_limits::quiet_NaN(); + return (mant == 0) ? std::numeric_limits::infinity() : std::numeric_limits::quiet_NaN(); default: return std::ldexp(mant + 1024, exp - 25); } }(); - return sax->number_float((half & 0x8000u) != 0 - ? static_cast(-val) - : static_cast(val), ""); + return sax->number_float((half & 0x8000u) != 0 ? static_cast(-val) : static_cast(val), ""); } - case 0xFA: // Single-Precision Float (four-byte IEEE 754) + case 0xFA: // Single-Precision Float (four-byte IEEE 754) { float number{}; return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); } - case 0xFB: // Double-Precision Float (eight-byte IEEE 754) + case 0xFB: // Double-Precision Float (eight-byte IEEE 754) { double number{}; return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); } - default: // anything else (0xFF is handled inside the other types) + default: // anything else (0xFF is handled inside the other types) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, chars_read, exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); } } } @@ -945,31 +961,31 @@ class binary_reader return get_string(input_format_t::cbor, static_cast(current) & 0x1Fu, result); } - case 0x78: // UTF-8 string (one-byte uint8_t for n follows) + case 0x78: // UTF-8 string (one-byte uint8_t for n follows) { std::uint8_t len{}; return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); } - case 0x79: // UTF-8 string (two-byte uint16_t for n follow) + case 0x79: // UTF-8 string (two-byte uint16_t for n follow) { std::uint16_t len{}; return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); } - case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) + case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) { std::uint32_t len{}; return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); } - case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) + case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) { std::uint64_t len{}; return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); } - case 0x7F: // UTF-8 string (indefinite length) + case 0x7F: // UTF-8 string (indefinite length) { while (get() != 0xFF) { @@ -986,8 +1002,16 @@ class binary_reader default: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, - exception_message(input_format_t::cbor, concat("expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token), "string"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create( + 113, + chars_read, + exception_message(input_format_t::cbor, + concat("expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token), + "string"), + nullptr)); } } } @@ -1041,35 +1065,31 @@ class binary_reader return get_binary(input_format_t::cbor, static_cast(current) & 0x1Fu, result); } - case 0x58: // Binary data (one-byte uint8_t for n follows) + case 0x58: // Binary data (one-byte uint8_t for n follows) { std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); + return get_number(input_format_t::cbor, len) && get_binary(input_format_t::cbor, len, result); } - case 0x59: // Binary data (two-byte uint16_t for n follow) + case 0x59: // Binary data (two-byte uint16_t for n follow) { std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); + return get_number(input_format_t::cbor, len) && get_binary(input_format_t::cbor, len, result); } - case 0x5A: // Binary data (four-byte uint32_t for n follow) + case 0x5A: // Binary data (four-byte uint32_t for n follow) { std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); + return get_number(input_format_t::cbor, len) && get_binary(input_format_t::cbor, len, result); } - case 0x5B: // Binary data (eight-byte uint64_t for n follow) + case 0x5B: // Binary data (eight-byte uint64_t for n follow) { std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); + return get_number(input_format_t::cbor, len) && get_binary(input_format_t::cbor, len, result); } - case 0x5F: // Binary data (indefinite length) + case 0x5F: // Binary data (indefinite length) { while (get() != 0xFF) { @@ -1086,8 +1106,16 @@ class binary_reader default: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, - exception_message(input_format_t::cbor, concat("expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token), "binary"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create( + 113, + chars_read, + exception_message(input_format_t::cbor, + concat("expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token), + "binary"), + nullptr)); } } } @@ -1098,8 +1126,7 @@ class binary_reader @param[in] tag_handler how CBOR tags should be treated @return whether array creation completed */ - bool get_cbor_array(const std::size_t len, - const cbor_tag_handler_t tag_handler) + bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler) { if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) { @@ -1136,8 +1163,7 @@ class binary_reader @param[in] tag_handler how CBOR tags should be treated @return whether object creation completed */ - bool get_cbor_object(const std::size_t len, - const cbor_tag_handler_t tag_handler) + bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler) { if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) { @@ -1402,118 +1428,118 @@ class binary_reader case 0xBD: case 0xBE: case 0xBF: - case 0xD9: // str 8 - case 0xDA: // str 16 - case 0xDB: // str 32 + case 0xD9: // str 8 + case 0xDA: // str 16 + case 0xDB: // str 32 { string_t s; return get_msgpack_string(s) && sax->string(s); } - case 0xC0: // nil + case 0xC0: // nil return sax->null(); - case 0xC2: // false + case 0xC2: // false return sax->boolean(false); - case 0xC3: // true + case 0xC3: // true return sax->boolean(true); - case 0xC4: // bin 8 - case 0xC5: // bin 16 - case 0xC6: // bin 32 - case 0xC7: // ext 8 - case 0xC8: // ext 16 - case 0xC9: // ext 32 - case 0xD4: // fixext 1 - case 0xD5: // fixext 2 - case 0xD6: // fixext 4 - case 0xD7: // fixext 8 - case 0xD8: // fixext 16 + case 0xC4: // bin 8 + case 0xC5: // bin 16 + case 0xC6: // bin 32 + case 0xC7: // ext 8 + case 0xC8: // ext 16 + case 0xC9: // ext 32 + case 0xD4: // fixext 1 + case 0xD5: // fixext 2 + case 0xD6: // fixext 4 + case 0xD7: // fixext 8 + case 0xD8: // fixext 16 { binary_t b; return get_msgpack_binary(b) && sax->binary(b); } - case 0xCA: // float 32 + case 0xCA: // float 32 { float number{}; return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); } - case 0xCB: // float 64 + case 0xCB: // float 64 { double number{}; return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); } - case 0xCC: // uint 8 + case 0xCC: // uint 8 { std::uint8_t number{}; return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); } - case 0xCD: // uint 16 + case 0xCD: // uint 16 { std::uint16_t number{}; return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); } - case 0xCE: // uint 32 + case 0xCE: // uint 32 { std::uint32_t number{}; return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); } - case 0xCF: // uint 64 + case 0xCF: // uint 64 { std::uint64_t number{}; return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); } - case 0xD0: // int 8 + case 0xD0: // int 8 { std::int8_t number{}; return get_number(input_format_t::msgpack, number) && sax->number_integer(number); } - case 0xD1: // int 16 + case 0xD1: // int 16 { std::int16_t number{}; return get_number(input_format_t::msgpack, number) && sax->number_integer(number); } - case 0xD2: // int 32 + case 0xD2: // int 32 { std::int32_t number{}; return get_number(input_format_t::msgpack, number) && sax->number_integer(number); } - case 0xD3: // int 64 + case 0xD3: // int 64 { std::int64_t number{}; return get_number(input_format_t::msgpack, number) && sax->number_integer(number); } - case 0xDC: // array 16 + case 0xDC: // array 16 { std::uint16_t len{}; return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast(len)); } - case 0xDD: // array 32 + case 0xDD: // array 32 { std::uint32_t len{}; return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast(len)); } - case 0xDE: // map 16 + case 0xDE: // map 16 { std::uint16_t len{}; return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast(len)); } - case 0xDF: // map 32 + case 0xDF: // map 32 { std::uint32_t len{}; return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast(len)); @@ -1554,11 +1580,13 @@ class binary_reader case 0xFF: return sax->number_integer(static_cast(current)); - default: // anything else + default: // anything else { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format_t::msgpack, concat("invalid byte: 0x", last_token), "value"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, concat("invalid byte: 0x", last_token), "value"), nullptr)); } } } @@ -1619,19 +1647,19 @@ class binary_reader return get_string(input_format_t::msgpack, static_cast(current) & 0x1Fu, result); } - case 0xD9: // str 8 + case 0xD9: // str 8 { std::uint8_t len{}; return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); } - case 0xDA: // str 16 + case 0xDA: // str 16 { std::uint16_t len{}; return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); } - case 0xDB: // str 32 + case 0xDB: // str 32 { std::uint32_t len{}; return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); @@ -1640,8 +1668,15 @@ class binary_reader default: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, - exception_message(input_format_t::msgpack, concat("expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token), "string"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(113, + chars_read, + exception_message(input_format_t::msgpack, + concat("expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token), + "string"), + nullptr)); } } } @@ -1659,103 +1694,83 @@ class binary_reader bool get_msgpack_binary(binary_t& result) { // helper function to set the subtype - auto assign_and_return_true = [&result](std::int8_t subtype) - { + auto assign_and_return_true = [&result](std::int8_t subtype) { result.set_subtype(static_cast(subtype)); return true; }; switch (current) { - case 0xC4: // bin 8 + case 0xC4: // bin 8 { std::uint8_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); + return get_number(input_format_t::msgpack, len) && get_binary(input_format_t::msgpack, len, result); } - case 0xC5: // bin 16 + case 0xC5: // bin 16 { std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); + return get_number(input_format_t::msgpack, len) && get_binary(input_format_t::msgpack, len, result); } - case 0xC6: // bin 32 + case 0xC6: // bin 32 { std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); + return get_number(input_format_t::msgpack, len) && get_binary(input_format_t::msgpack, len, result); } - case 0xC7: // ext 8 + case 0xC7: // ext 8 { std::uint8_t len{}; std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, len) && get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && assign_and_return_true(subtype); } - case 0xC8: // ext 16 + case 0xC8: // ext 16 { std::uint16_t len{}; std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, len) && get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && assign_and_return_true(subtype); } - case 0xC9: // ext 32 + case 0xC9: // ext 32 { std::uint32_t len{}; std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, len) && get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && assign_and_return_true(subtype); } - case 0xD4: // fixext 1 + case 0xD4: // fixext 1 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 1, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 1, result) && assign_and_return_true(subtype); } - case 0xD5: // fixext 2 + case 0xD5: // fixext 2 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 2, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 2, result) && assign_and_return_true(subtype); } - case 0xD6: // fixext 4 + case 0xD6: // fixext 4 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 4, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 4, result) && assign_and_return_true(subtype); } - case 0xD7: // fixext 8 + case 0xD7: // fixext 8 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 8, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 8, result) && assign_and_return_true(subtype); } - case 0xD8: // fixext 16 + case 0xD8: // fixext 16 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 16, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 16, result) && assign_and_return_true(subtype); } default: // LCOV_EXCL_LINE @@ -2034,10 +2049,14 @@ class binary_reader } if (number < 0) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, - exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + parse_error::create(113, + chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), + nullptr)); } - result = static_cast(number); // NOLINT(bugprone-signed-char-misuse,cert-str34-c): number is not a char + result = static_cast(number); // NOLINT(bugprone-signed-char-misuse,cert-str34-c): number is not a char return true; } @@ -2050,8 +2069,12 @@ class binary_reader } if (number < 0) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, - exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + parse_error::create(113, + chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), + nullptr)); } result = static_cast(number); return true; @@ -2066,8 +2089,12 @@ class binary_reader } if (number < 0) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, - exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + parse_error::create(113, + chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), + nullptr)); } result = static_cast(number); return true; @@ -2082,13 +2109,18 @@ class binary_reader } if (number < 0) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, - exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + parse_error::create(113, + chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), + nullptr)); } if (!value_in_range_of(number)) { - return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, - exception_message(input_format, "integer value overflow", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + out_of_range::create(408, exception_message(input_format, "integer value overflow", "size"), nullptr)); } result = static_cast(number); return true; @@ -2137,8 +2169,9 @@ class binary_reader } if (!value_in_range_of(number)) { - return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, - exception_message(input_format, "integer value overflow", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + out_of_range::create(408, exception_message(input_format, "integer value overflow", "size"), nullptr)); } result = detail::conditional_static_cast(number); return true; @@ -2150,25 +2183,28 @@ class binary_reader { break; } - if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array + if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr)); } std::vector dim; if (JSON_HEDLEY_UNLIKELY(!get_ubjson_ndarray_size(dim))) { return false; } - if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1)) // return normal array size if 1D row vector + if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1)) // return normal array size if 1D row vector { result = dim.at(dim.size() - 1); return true; } if (!dim.empty()) // if ndarray, convert to an object in JData annotated array format { - for (auto i : dim) // test if any dimension in an ndarray is 0, if so, return a 1D empty container + for (auto i : dim) // test if any dimension in an ndarray is 0, if so, return a 1D empty container { - if ( i == 0 ) + if (i == 0) { result = 0; return true; @@ -2184,9 +2220,14 @@ class binary_reader for (auto i : dim) { result *= i; - if (result == 0 || result == npos) // because dim elements shall not have zeros, result = 0 means overflow happened; it also can't be npos as it is used to initialize size in get_ubjson_size_type() + if (result == 0 || + result == + npos) // because dim elements shall not have zeros, result = 0 means overflow happened; it also can't be npos as it is used to initialize size in get_ubjson_size_type() { - return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "excessive ndarray size caused overflow", "size"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + out_of_range::create(408, exception_message(input_format, "excessive ndarray size caused overflow", "size"), nullptr)); } if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(static_cast(i)))) { @@ -2230,8 +2271,8 @@ class binary_reader */ bool get_ubjson_size_type(std::pair& result, bool inside_ndarray = false) { - result.first = npos; // size - result.second = 0; // type + result.first = npos; // size + result.second = 0; // type bool is_ndarray = false; get_ignore_noop(); @@ -2239,12 +2280,17 @@ class binary_reader if (current == '$') { result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (input_format == input_format_t::bjdata - && JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second))) + if (input_format == input_format_t::bjdata && + JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second))) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format, concat("marker 0x", last_token, " is not a permitted optimized array type"), "type"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format, concat("marker 0x", last_token, " is not a permitted optimized array type"), "type"), + nullptr)); } if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "type"))) @@ -2260,8 +2306,13 @@ class binary_reader return false; } auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format, concat("expected '#' after type information; last byte: 0x", last_token), "size"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format, concat("expected '#' after type information; last byte: 0x", last_token), "size"), + nullptr)); } const bool is_error = get_ubjson_size_value(result.first, is_ndarray); @@ -2269,10 +2320,12 @@ class binary_reader { if (inside_ndarray) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read, - exception_message(input_format, "ndarray can not be recursive", "size"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + parse_error::create(112, chars_read, exception_message(input_format, "ndarray can not be recursive", "size"), nullptr)); } - result.second |= (1 << 8); // use bit 8 to indicate ndarray, all UBJSON and BJData markers should be ASCII letters + result.second |= (1 << 8); // use bit 8 to indicate ndarray, all UBJSON and BJData markers should be ASCII letters } return is_error; } @@ -2282,8 +2335,10 @@ class binary_reader const bool is_error = get_ubjson_size_value(result.first, is_ndarray); if (input_format == input_format_t::bjdata && is_ndarray) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read, - exception_message(input_format, "ndarray requires both type and size", "size"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + parse_error::create(112, chars_read, exception_message(input_format, "ndarray requires both type and size", "size"), nullptr)); } return is_error; } @@ -2399,27 +2454,22 @@ class binary_reader // half-precision floating-point numbers in the C language // is shown in Fig. 3. const auto half = static_cast((byte2 << 8u) + byte1); - const double val = [&half] - { + const double val = [&half] { const int exp = (half >> 10u) & 0x1Fu; const unsigned int mant = half & 0x3FFu; - JSON_ASSERT(0 <= exp&& exp <= 32); + JSON_ASSERT(0 <= exp && exp <= 32); JSON_ASSERT(mant <= 1024); switch (exp) { case 0: return std::ldexp(mant, -24); case 31: - return (mant == 0) - ? std::numeric_limits::infinity() - : std::numeric_limits::quiet_NaN(); + return (mant == 0) ? std::numeric_limits::infinity() : std::numeric_limits::quiet_NaN(); default: return std::ldexp(mant + 1024, exp - 25); } }(); - return sax->number_float((half & 0x8000u) != 0 - ? static_cast(-val) - : static_cast(val), ""); + return sax->number_float((half & 0x8000u) != 0 ? static_cast(-val) : static_cast(val), ""); } case 'd': @@ -2449,8 +2499,14 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(current > 127)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, - exception_message(input_format, concat("byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token), "char"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create( + 113, + chars_read, + exception_message(input_format, concat("byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token), "char"), + nullptr)); } string_t s(1, static_cast(current)); return sax->string(s); @@ -2468,11 +2524,13 @@ class binary_reader case '{': // object return get_ubjson_object(); - default: // anything else + default: // anything else break; } auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "value"), nullptr)); + return sax->parse_error(chars_read, + last_token, + parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "value"), nullptr)); } /*! @@ -2492,19 +2550,20 @@ class binary_reader if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0) { size_and_type.second &= ~(static_cast(1) << 8); // use bit 8 to indicate ndarray, here we remove the bit to restore the type marker - auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](const bjd_type & p, char_int_type t) - { + auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](const bjd_type& p, char_int_type t) { return p.first < t; }); string_t key = "_ArrayType_"; if (JSON_HEDLEY_UNLIKELY(it == bjd_types_map.end() || it->first != size_and_type.second)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format, "invalid byte: 0x" + last_token, "type"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "type"), nullptr)); } - string_t type = it->second; // sax->string() takes a reference + string_t type = it->second; // sax->string() takes a reference if (JSON_HEDLEY_UNLIKELY(!sax->key(key) || !sax->string(type))) { return false; @@ -2516,7 +2575,7 @@ class binary_reader } key = "_ArrayData_"; - if (JSON_HEDLEY_UNLIKELY(!sax->key(key) || !sax->start_array(size_and_type.first) )) + if (JSON_HEDLEY_UNLIKELY(!sax->key(key) || !sax->start_array(size_and_type.first))) { return false; } @@ -2598,8 +2657,13 @@ class binary_reader if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format, "BJData object does not support ND-array size in optimized format", "object"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format, "BJData object does not support ND-array size in optimized format", "object"), + nullptr)); } string_t key; @@ -2703,8 +2767,13 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input)) { - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, - exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), nullptr)); + return sax->parse_error( + chars_read, + number_string, + parse_error::create(115, + chars_read, + exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), + nullptr)); } switch (result_number) @@ -2730,8 +2799,14 @@ class binary_reader case token_type::end_of_input: case token_type::literal_or_value: default: - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, - exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), nullptr)); + return sax->parse_error( + chars_read, + number_string, + parse_error::create( + 115, + chars_read, + exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), + nullptr)); } } @@ -2762,8 +2837,7 @@ class binary_reader do { get(); - } - while (current == 'N'); + } while (current == 'N'); return current; } @@ -2803,7 +2877,7 @@ class binary_reader } else { - vec[i] = static_cast(current); // LCOV_EXCL_LINE + vec[i] = static_cast(current); // LCOV_EXCL_LINE } } @@ -2827,9 +2901,7 @@ class binary_reader the input before we run out of string memory. */ template - bool get_string(const input_format_t format, - const NumberType len, - string_t& result) + bool get_string(const input_format_t format, const NumberType len, string_t& result) { bool success = true; for (NumberType i = 0; i < len; i++) @@ -2860,9 +2932,7 @@ class binary_reader the input before we run out of memory. */ template - bool get_binary(const input_format_t format, - const NumberType len, - binary_t& result) + bool get_binary(const input_format_t format, const NumberType len, binary_t& result) { bool success = true; for (NumberType i = 0; i < len; i++) @@ -2888,7 +2958,8 @@ class binary_reader { if (JSON_HEDLEY_UNLIKELY(current == char_traits::eof())) { - return sax->parse_error(chars_read, "", + return sax->parse_error(chars_read, + "", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr)); } return true; @@ -2899,9 +2970,10 @@ class binary_reader */ std::string get_token_string() const { - std::array cr{{}}; - static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - return std::string{cr.data()}; + std::array cr{ {} }; + static_cast( + (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + return std::string{ cr.data() }; } /*! @@ -2910,9 +2982,7 @@ class binary_reader @param[in] context further context information @return a message string to use in the parse_error exceptions */ - std::string exception_message(const input_format_t format, - const std::string& detail, - const std::string& context) const + std::string exception_message(const input_format_t format, const std::string& detail, const std::string& context) const { std::string error_msg = "syntax error while parsing "; @@ -2938,9 +3008,9 @@ class binary_reader error_msg += "BJData"; break; - case input_format_t::json: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE + case input_format_t::json: // LCOV_EXCL_LINE + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE } return concat(error_msg, ' ', context, ": ", detail); @@ -2968,41 +3038,37 @@ class binary_reader json_sax_t* sax = nullptr; // excluded markers in bjdata optimized type -#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \ - make_array('F', 'H', 'N', 'S', 'T', 'Z', '[', '{') - -#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \ - make_array( \ - bjd_type{'C', "char"}, \ - bjd_type{'D', "double"}, \ - bjd_type{'I', "int16"}, \ - bjd_type{'L', "int64"}, \ - bjd_type{'M', "uint64"}, \ - bjd_type{'U', "uint8"}, \ - bjd_type{'d', "single"}, \ - bjd_type{'i', "int8"}, \ - bjd_type{'l', "int32"}, \ - bjd_type{'m', "uint32"}, \ - bjd_type{'u', "uint16"}) - - JSON_PRIVATE_UNLESS_TESTED: +#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ make_array('F', 'H', 'N', 'S', 'T', 'Z', '[', '{') + +#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \ + make_array(bjd_type{ 'C', "char" }, \ + bjd_type{ 'D', "double" }, \ + bjd_type{ 'I', "int16" }, \ + bjd_type{ 'L', "int64" }, \ + bjd_type{ 'M', "uint64" }, \ + bjd_type{ 'U', "uint8" }, \ + bjd_type{ 'd', "single" }, \ + bjd_type{ 'i', "int8" }, \ + bjd_type{ 'l', "int32" }, \ + bjd_type{ 'm', "uint32" }, \ + bjd_type{ 'u', "uint16" }) + + JSON_PRIVATE_UNLESS_TESTED : // lookup tables // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes) - const decltype(JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_) bjd_optimized_type_markers = - JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_; + const decltype(JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_) bjd_optimized_type_markers = JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_; using bjd_type = std::pair; // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes) - const decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_) bjd_types_map = - JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_; + const decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_) bjd_types_map = JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_; #undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ #undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ }; #ifndef JSON_HAS_CPP_17 - template - constexpr std::size_t binary_reader::npos; +template +constexpr std::size_t binary_reader::npos; #endif } // namespace detail diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index 33fca3e4b9..7e104d0727 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -8,15 +8,15 @@ #pragma once -#include // array -#include // size_t -#include // strlen -#include // begin, end, iterator_traits, random_access_iterator_tag, distance, next -#include // shared_ptr, make_shared, addressof -#include // accumulate -#include // string, char_traits -#include // enable_if, is_base_of, is_pointer, is_integral, remove_pointer -#include // pair, declval +#include // array +#include // size_t +#include // strlen +#include // begin, end, iterator_traits, random_access_iterator_tag, distance, next +#include // shared_ptr, make_shared, addressof +#include // accumulate +#include // string, char_traits +#include // enable_if, is_base_of, is_pointer, is_integral, remove_pointer +#include // pair, declval #ifndef JSON_NO_IO #include // FILE * @@ -32,7 +32,15 @@ namespace detail { /// the supported input formats -enum class input_format_t { json, cbor, msgpack, ubjson, bson, bjdata }; +enum class input_format_t +{ + json, + cbor, + msgpack, + ubjson, + bson, + bjdata +}; //////////////////// // input adapters // @@ -50,7 +58,7 @@ class file_input_adapter JSON_HEDLEY_NON_NULL(2) explicit file_input_adapter(std::FILE* f) noexcept - : m_file(f) + : m_file(f) { JSON_ASSERT(m_file != nullptr); } @@ -97,7 +105,8 @@ class input_stream_adapter } explicit input_stream_adapter(std::istream& i) - : is(&i), sb(i.rdbuf()) + : is(&i) + , sb(i.rdbuf()) {} // delete because of pointer members @@ -106,7 +115,8 @@ class input_stream_adapter input_stream_adapter& operator=(input_stream_adapter&&) = delete; input_stream_adapter(input_stream_adapter&& rhs) noexcept - : is(rhs.is), sb(rhs.sb) + : is(rhs.is) + , sb(rhs.sb) { rhs.is = nullptr; rhs.sb = nullptr; @@ -142,7 +152,8 @@ class iterator_input_adapter using char_type = typename std::iterator_traits::value_type; iterator_input_adapter(IteratorType first, IteratorType last) - : current(std::move(first)), end(std::move(last)) + : current(std::move(first)) + , end(std::move(last)) {} typename char_traits::int_type get_character() @@ -177,10 +188,8 @@ template struct wide_string_input_helper { // UTF-32 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) + static void + fill_buffer(BaseInputAdapter& input, std::array::int_type, 4>& utf8_bytes, size_t& utf8_bytes_index, size_t& utf8_bytes_filled) { utf8_bytes_index = 0; @@ -235,10 +244,8 @@ template struct wide_string_input_helper { // UTF-16 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) + static void + fill_buffer(BaseInputAdapter& input, std::array::int_type, 4>& utf8_bytes, size_t& utf8_bytes_index, size_t& utf8_bytes_filled) { utf8_bytes_index = 0; @@ -301,7 +308,8 @@ class wide_string_input_adapter using char_type = char; wide_string_input_adapter(BaseInputAdapter base) - : base_adapter(base) {} + : base_adapter(base) + {} typename std::char_traits::int_type get_character() noexcept { @@ -330,7 +338,7 @@ class wide_string_input_adapter } /// a buffer for UTF-8 bytes - std::array::int_type, 4> utf8_bytes = {{0, 0, 0, 0}}; + std::array::int_type, 4> utf8_bytes = { { 0, 0, 0, 0 } }; /// index to the utf8_codes array for the next valid byte std::size_t utf8_bytes_index = 0; @@ -394,19 +402,19 @@ using std::begin; using std::end; template -struct container_input_adapter_factory {}; +struct container_input_adapter_factory +{}; template -struct container_input_adapter_factory< ContainerType, - void_t()), end(std::declval()))>> - { - using adapter_type = decltype(input_adapter(begin(std::declval()), end(std::declval()))); - - static adapter_type create(const ContainerType& container) +struct container_input_adapter_factory()), end(std::declval()))>> { - return input_adapter(begin(container), end(container)); -} - }; + using adapter_type = decltype(input_adapter(begin(std::declval()), end(std::declval()))); + + static adapter_type create(const ContainerType& container) + { + return input_adapter(begin(container), end(container)); + } +}; } // namespace container_input_adapter_factory_impl @@ -437,13 +445,11 @@ inline input_stream_adapter input_adapter(std::istream&& stream) using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval(), std::declval())); // Null-delimited strings, and the like. -template < typename CharT, - typename std::enable_if < - std::is_pointer::value&& - !std::is_array::value&& - std::is_integral::type>::value&& - sizeof(typename std::remove_pointer::type) == 1, - int >::type = 0 > +template< + typename CharT, + typename std::enable_if::value && !std::is_array::value && + std::is_integral::type>::value && sizeof(typename std::remove_pointer::type) == 1, + int>::type = 0> contiguous_bytes_input_adapter input_adapter(CharT b) { auto length = std::strlen(reinterpret_cast(b)); @@ -452,7 +458,8 @@ contiguous_bytes_input_adapter input_adapter(CharT b) } template -auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) +auto input_adapter(T (&array)[N]) + -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) { return input_adapter(array, array + N); } @@ -463,25 +470,24 @@ auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) / class span_input_adapter { public: - template < typename CharT, - typename std::enable_if < - std::is_pointer::value&& - std::is_integral::type>::value&& - sizeof(typename std::remove_pointer::type) == 1, - int >::type = 0 > + template::value && std::is_integral::type>::value && + sizeof(typename std::remove_pointer::type) == 1, + int>::type = 0> span_input_adapter(CharT b, std::size_t l) - : ia(reinterpret_cast(b), reinterpret_cast(b) + l) {} + : ia(reinterpret_cast(b), reinterpret_cast(b) + l) + {} - template::iterator_category, std::random_access_iterator_tag>::value, - int>::type = 0> + template< + class IteratorType, + typename std::enable_if::iterator_category, std::random_access_iterator_tag>::value, int>::type = 0> span_input_adapter(IteratorType first, IteratorType last) - : ia(input_adapter(first, last)) {} + : ia(input_adapter(first, last)) + {} contiguous_bytes_input_adapter&& get() { - return std::move(ia); // NOLINT(hicpp-move-const-arg,performance-move-const-arg) + return std::move(ia); // NOLINT(hicpp-move-const-arg,performance-move-const-arg) } private: diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp index c772521cd8..966969fe28 100644 --- a/include/nlohmann/detail/input/json_sax.hpp +++ b/include/nlohmann/detail/input/json_sax.hpp @@ -9,9 +9,9 @@ #pragma once #include -#include // string -#include // move -#include // vector +#include // string +#include // move +#include // vector #include #include @@ -130,9 +130,7 @@ struct json_sax @param[in] ex an exception object describing the error @return whether parsing should proceed (must return false) */ - virtual bool parse_error(std::size_t position, - const std::string& last_token, - const detail::exception& ex) = 0; + virtual bool parse_error(std::size_t position, const std::string& last_token, const detail::exception& ex) = 0; json_sax() = default; json_sax(const json_sax&) = default; @@ -173,14 +171,15 @@ class json_sax_dom_parser @param[in] allow_exceptions_ whether parse errors yield exceptions */ explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true) - : root(r), allow_exceptions(allow_exceptions_) + : root(r) + , allow_exceptions(allow_exceptions_) {} // make class move-only json_sax_dom_parser(const json_sax_dom_parser&) = delete; - json_sax_dom_parser(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) + json_sax_dom_parser(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete; - json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) + json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) ~json_sax_dom_parser() = default; bool null() @@ -280,8 +279,7 @@ class json_sax_dom_parser } template - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, - const Exception& ex) + bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const Exception& ex) { errored = true; static_cast(ex); @@ -305,8 +303,7 @@ class json_sax_dom_parser object to which we can add elements */ template - JSON_HEDLEY_RETURNS_NON_NULL - BasicJsonType* handle_value(Value&& v) + JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType* handle_value(Value&& v) { if (ref_stack.empty()) { @@ -331,7 +328,7 @@ class json_sax_dom_parser /// the parsed JSON value BasicJsonType& root; /// stack to model hierarchy of values - std::vector ref_stack {}; + std::vector ref_stack{}; /// helper to hold the reference for the next object element BasicJsonType* object_element = nullptr; /// whether a syntax error occurred @@ -352,19 +349,19 @@ class json_sax_dom_callback_parser using parser_callback_t = typename BasicJsonType::parser_callback_t; using parse_event_t = typename BasicJsonType::parse_event_t; - json_sax_dom_callback_parser(BasicJsonType& r, - const parser_callback_t cb, - const bool allow_exceptions_ = true) - : root(r), callback(cb), allow_exceptions(allow_exceptions_) + json_sax_dom_callback_parser(BasicJsonType& r, const parser_callback_t cb, const bool allow_exceptions_ = true) + : root(r) + , callback(cb) + , allow_exceptions(allow_exceptions_) { keep_stack.push_back(true); } // make class move-only json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete; - json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) + json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) json_sax_dom_callback_parser& operator=(const json_sax_dom_callback_parser&) = delete; - json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) + json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) ~json_sax_dom_callback_parser() = default; bool null() @@ -530,8 +527,7 @@ class json_sax_dom_callback_parser } template - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, - const Exception& ex) + bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const Exception& ex) { errored = true; static_cast(ex); @@ -572,7 +568,7 @@ class json_sax_dom_callback_parser // container if (!keep_stack.back()) { - return {false, nullptr}; + return { false, nullptr }; } // create value @@ -584,20 +580,20 @@ class json_sax_dom_callback_parser // do not handle this value if we just learnt it shall be discarded if (!keep) { - return {false, nullptr}; + return { false, nullptr }; } if (ref_stack.empty()) { root = std::move(value); - return {true, & root}; + return { true, &root }; } // skip this value if we already decided to skip the parent // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360) if (!ref_stack.back()) { - return {false, nullptr}; + return { false, nullptr }; } // we now only expect arrays and objects @@ -607,7 +603,7 @@ class json_sax_dom_callback_parser if (ref_stack.back()->is_array()) { ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value)); - return {true, & (ref_stack.back()->m_data.m_value.array->back())}; + return { true, &(ref_stack.back()->m_data.m_value.array->back()) }; } // object @@ -619,22 +615,22 @@ class json_sax_dom_callback_parser if (!store_element) { - return {false, nullptr}; + return { false, nullptr }; } JSON_ASSERT(object_element); *object_element = std::move(value); - return {true, object_element}; + return { true, object_element }; } /// the parsed JSON value BasicJsonType& root; /// stack to model hierarchy of values - std::vector ref_stack {}; + std::vector ref_stack{}; /// stack to manage which values to keep - std::vector keep_stack {}; + std::vector keep_stack{}; /// stack to manage which object keys to keep - std::vector key_keep_stack {}; + std::vector key_keep_stack{}; /// helper to hold the reference for the next object element BasicJsonType* object_element = nullptr; /// whether a syntax error occurred diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 4b3bf77d62..32ad58e06a 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -8,15 +8,15 @@ #pragma once -#include // array -#include // localeconv -#include // size_t -#include // snprintf -#include // strtof, strtod, strtold, strtoll, strtoull -#include // initializer_list -#include // char_traits, string -#include // move -#include // vector +#include // array +#include // localeconv +#include // size_t +#include // snprintf +#include // strtof, strtod, strtold, strtoll, strtoull +#include // initializer_list +#include // char_traits, string +#include // move +#include // vector #include #include @@ -97,7 +97,7 @@ class lexer_base case token_type::literal_or_value: return "'[', '{', or a literal"; // LCOV_EXCL_START - default: // catch non-enum values + default: // catch non-enum values return "unknown token"; // LCOV_EXCL_STOP } @@ -122,16 +122,16 @@ class lexer : public lexer_base using token_type = typename lexer_base::token_type; explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) noexcept - : ia(std::move(adapter)) - , ignore_comments(ignore_comments_) - , decimal_point_char(static_cast(get_decimal_point())) + : ia(std::move(adapter)) + , ignore_comments(ignore_comments_) + , decimal_point_char(static_cast(get_decimal_point())) {} // delete because of pointer members lexer(const lexer&) = delete; - lexer(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) + lexer(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) lexer& operator=(lexer&) = delete; - lexer& operator=(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) + lexer& operator=(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) ~lexer() = default; private: @@ -223,7 +223,7 @@ class lexer : public lexer_base for (auto range = ranges.begin(); range != ranges.end(); ++range) { get(); - if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) // NOLINT(bugprone-inc-dec-in-conditions) + if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) // NOLINT(bugprone-inc-dec-in-conditions) { add(current); } @@ -320,7 +320,7 @@ class lexer : public lexer_base case 'u': { const int codepoint1 = get_codepoint(); - int codepoint = codepoint1; // start with codepoint1 + int codepoint = codepoint1; // start with codepoint1 if (JSON_HEDLEY_UNLIKELY(codepoint1 == -1)) { @@ -347,14 +347,14 @@ class lexer : public lexer_base { // overwrite codepoint codepoint = static_cast( - // high surrogate occupies the most significant 22 bits - (static_cast(codepoint1) << 10u) - // low surrogate occupies the least significant 15 bits - + static_cast(codepoint2) - // there is still the 0xD800, 0xDC00 and 0x10000 noise - // in the result, so we have to subtract with: - // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00 - - 0x35FDC00u); + // high surrogate occupies the most significant 22 bits + (static_cast(codepoint1) << 10u) + // low surrogate occupies the least significant 15 bits + + static_cast(codepoint2) + // there is still the 0xD800, 0xDC00 and 0x10000 noise + // in the result, so we have to subtract with: + // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00 + - 0x35FDC00u); } else { @@ -745,7 +745,7 @@ class lexer : public lexer_base case 0xDE: case 0xDF: { - if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF}))) + if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({ 0x80, 0xBF }))) { return token_type::parse_error; } @@ -755,7 +755,7 @@ class lexer : public lexer_base // U+0800..U+0FFF: bytes E0 A0..BF 80..BF case 0xE0: { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0xA0, 0xBF, 0x80, 0xBF })))) { return token_type::parse_error; } @@ -779,7 +779,7 @@ class lexer : public lexer_base case 0xEE: case 0xEF: { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x80, 0xBF, 0x80, 0xBF })))) { return token_type::parse_error; } @@ -789,7 +789,7 @@ class lexer : public lexer_base // U+D000..U+D7FF: bytes ED 80..9F 80..BF case 0xED: { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x80, 0x9F, 0x80, 0xBF })))) { return token_type::parse_error; } @@ -799,7 +799,7 @@ class lexer : public lexer_base // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF case 0xF0: { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF })))) { return token_type::parse_error; } @@ -811,7 +811,7 @@ class lexer : public lexer_base case 0xF2: case 0xF3: { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF })))) { return token_type::parse_error; } @@ -821,7 +821,7 @@ class lexer : public lexer_base // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF case 0xF4: { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF })))) { return token_type::parse_error; } @@ -1006,8 +1006,8 @@ class lexer : public lexer_base } // all other characters are rejected outside scan_number() - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE } scan_number_minus: @@ -1185,8 +1185,7 @@ class lexer : public lexer_base default: { - error_message = - "invalid number; expected '+', '-', or digit after exponent"; + error_message = "invalid number; expected '+', '-', or digit after exponent"; return token_type::parse_error; } } @@ -1245,7 +1244,7 @@ class lexer : public lexer_base // we are done scanning a number) unget(); - char* endptr = nullptr; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + char* endptr = nullptr; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) errno = 0; // try to parse integers first and fall back to floats @@ -1298,8 +1297,7 @@ class lexer : public lexer_base @param[in] return_type the token type to return on success */ JSON_HEDLEY_NON_NULL(2) - token_type scan_literal(const char_type* literal_text, const std::size_t length, - token_type return_type) + token_type scan_literal(const char_type* literal_text, const std::size_t length, token_type return_type) { JSON_ASSERT(char_traits::to_char_type(current) == literal_text[0]); for (std::size_t i = 1; i < length; ++i) @@ -1455,8 +1453,9 @@ class lexer : public lexer_base if (static_cast(c) <= '\x1F') { // escape control characters - std::array cs{{}}; - static_cast((std::snprintf)(cs.data(), cs.size(), "", static_cast(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + std::array cs{ {} }; + static_cast(( // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + std::snprintf)(cs.data(), cs.size(), "", static_cast(c))); result += cs.data(); } else @@ -1503,8 +1502,7 @@ class lexer : public lexer_base do { get(); - } - while (current == ' ' || current == '\t' || current == '\n' || current == '\r'); + } while (current == ' ' || current == '\t' || current == '\n' || current == '\r'); } token_type scan() @@ -1550,17 +1548,25 @@ class lexer : public lexer_base // literals case 't': { - std::array true_literal = {{static_cast('t'), static_cast('r'), static_cast('u'), static_cast('e')}}; + std::array true_literal = { + { static_cast('t'), static_cast('r'), static_cast('u'), static_cast('e') } + }; return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); } case 'f': { - std::array false_literal = {{static_cast('f'), static_cast('a'), static_cast('l'), static_cast('s'), static_cast('e')}}; + std::array false_literal = { { static_cast('f'), + static_cast('a'), + static_cast('l'), + static_cast('s'), + static_cast('e') } }; return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); } case 'n': { - std::array null_literal = {{static_cast('n'), static_cast('u'), static_cast('l'), static_cast('l')}}; + std::array null_literal = { + { static_cast('n'), static_cast('u'), static_cast('l'), static_cast('l') } + }; return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); } @@ -1609,13 +1615,13 @@ class lexer : public lexer_base bool next_unget = false; /// the start position of the current token - position_t position {}; + position_t position{}; /// raw input token string (for error messages) - std::vector token_string {}; + std::vector token_string{}; /// buffer for variable-length tokens (numbers, strings) - string_t token_buffer {}; + string_t token_buffer{}; /// a description of occurred lexer errors const char* error_message = ""; diff --git a/include/nlohmann/detail/input/parser.hpp b/include/nlohmann/detail/input/parser.hpp index bdf85ba292..40893e219d 100644 --- a/include/nlohmann/detail/input/parser.hpp +++ b/include/nlohmann/detail/input/parser.hpp @@ -8,12 +8,12 @@ #pragma once -#include // isfinite -#include // uint8_t -#include // function -#include // string -#include // move -#include // vector +#include // isfinite +#include // uint8_t +#include // function +#include // string +#include // move +#include // vector #include #include @@ -48,8 +48,7 @@ enum class parse_event_t : std::uint8_t }; template -using parser_callback_t = - std::function; +using parser_callback_t = std::function; /*! @brief syntax analysis @@ -72,9 +71,9 @@ class parser const parser_callback_t cb = nullptr, const bool allow_exceptions_ = true, const bool skip_comments = false) - : callback(cb) - , m_lexer(std::move(adapter), skip_comments) - , allow_exceptions(allow_exceptions_) + : callback(cb) + , m_lexer(std::move(adapter), skip_comments) + , allow_exceptions(allow_exceptions_) { // read first token get_token(); @@ -102,8 +101,7 @@ class parser { sdp.parse_error(m_lexer.get_position(), m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), - exception_message(token_type::end_of_input, "value"), nullptr)); + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), nullptr)); } // in case of an error, return discarded value @@ -160,7 +158,7 @@ class parser JSON_HEDLEY_NON_NULL(2) bool sax_parse(SAX* sax, const bool strict = true) { - (void)detail::is_sax_static_asserts {}; + (void)detail::is_sax_static_asserts{}; const bool result = sax_parse_internal(sax); // strict mode: next byte must be EOF @@ -212,9 +210,10 @@ class parser // parse key if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); } if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) { @@ -224,9 +223,10 @@ class parser // parse separator (:) if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); } // remember we are now inside an object @@ -337,23 +337,28 @@ class parser case token_type::parse_error: { // using "uninitialized" to avoid "expected" message - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr)); } case token_type::end_of_input: { if (JSON_HEDLEY_UNLIKELY(m_lexer.get_position().chars_read_total == 1)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), - "attempting to parse an empty input; check that your input string or stream contains the expected JSON", nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, + m_lexer.get_position(), + "attempting to parse an empty input; check that your input string or stream contains the expected JSON", + nullptr)); } - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); } case token_type::uninitialized: case token_type::end_array: @@ -361,11 +366,12 @@ class parser case token_type::name_separator: case token_type::value_separator: case token_type::literal_or_value: - default: // the last token was unexpected + default: // the last token was unexpected { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); } } } @@ -422,9 +428,10 @@ class parser // parse key if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); } if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) @@ -435,9 +442,10 @@ class parser // parse separator (:) if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); } // parse values @@ -488,8 +496,7 @@ class parser if (last_token == token_type::parse_error) { - error_msg += concat(m_lexer.get_error_message(), "; last read: '", - m_lexer.get_token_string(), '\''); + error_msg += concat(m_lexer.get_error_message(), "; last read: '", m_lexer.get_token_string(), '\''); } else { diff --git a/include/nlohmann/detail/input/position_t.hpp b/include/nlohmann/detail/input/position_t.hpp index 8ac7c78cfd..a5e0808f40 100644 --- a/include/nlohmann/detail/input/position_t.hpp +++ b/include/nlohmann/detail/input/position_t.hpp @@ -8,7 +8,7 @@ #pragma once -#include // size_t +#include // size_t #include diff --git a/include/nlohmann/detail/iterators/internal_iterator.hpp b/include/nlohmann/detail/iterators/internal_iterator.hpp index 2991ee6930..c0db658e50 100644 --- a/include/nlohmann/detail/iterators/internal_iterator.hpp +++ b/include/nlohmann/detail/iterators/internal_iterator.hpp @@ -21,14 +21,15 @@ namespace detail @note This structure could easily be a union, but MSVC currently does not allow unions members with complex constructors, see https://github.com/nlohmann/json/pull/105. */ -template struct internal_iterator +template +struct internal_iterator { /// iterator for JSON objects - typename BasicJsonType::object_t::iterator object_iterator {}; + typename BasicJsonType::object_t::iterator object_iterator{}; /// iterator for JSON arrays - typename BasicJsonType::array_t::iterator array_iterator {}; + typename BasicJsonType::array_t::iterator array_iterator{}; /// generic iterator for all other types - primitive_iterator_t primitive_iterator {}; + primitive_iterator_t primitive_iterator{}; }; } // namespace detail diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp index 4447091347..da27f6c58a 100644 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/include/nlohmann/detail/iterators/iter_impl.hpp @@ -8,8 +8,8 @@ #pragma once -#include // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next -#include // conditional, is_const, remove_const +#include // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next +#include // conditional, is_const, remove_const #include #include @@ -24,8 +24,10 @@ namespace detail { // forward declare, to be able to friend it later on -template class iteration_proxy; -template class iteration_proxy_value; +template +class iteration_proxy; +template +class iteration_proxy_value; /*! @brief a template for a bidirectional iterator for the @ref basic_json class @@ -44,10 +46,11 @@ This class implements a both iterators (iterator and const_iterator) for the iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593) */ template -class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) +class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) { /// the iterator with BasicJsonType of different const-ness - using other_iter_impl = iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; + using other_iter_impl = + iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; /// allow basic_json to access private members friend other_iter_impl; friend BasicJsonType; @@ -57,11 +60,10 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci using object_t = typename BasicJsonType::object_t; using array_t = typename BasicJsonType::array_t; // make sure BasicJsonType is basic_json or const basic_json - static_assert(is_basic_json::type>::value, - "iter_impl only accepts (const) basic_json"); + static_assert(is_basic_json::type>::value, "iter_impl only accepts (const) basic_json"); // superficial check for the LegacyBidirectionalIterator named requirement - static_assert(std::is_base_of::value - && std::is_base_of::iterator_category>::value, + static_assert(std::is_base_of::value && + std::is_base_of::iterator_category>::value, "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement."); public: @@ -77,14 +79,11 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci /// a type to represent differences between iterators using difference_type = typename BasicJsonType::difference_type; /// defines a pointer to the type iterated over (value_type) - using pointer = typename std::conditional::value, - typename BasicJsonType::const_pointer, - typename BasicJsonType::pointer>::type; + using pointer = + typename std::conditional::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer>::type; /// defines a reference to the type iterated over (value_type) using reference = - typename std::conditional::value, - typename BasicJsonType::const_reference, - typename BasicJsonType::reference>::type; + typename std::conditional::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference>::type; iter_impl() = default; ~iter_impl() = default; @@ -97,7 +96,8 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci @pre object != nullptr @post The iterator is initialized; i.e. `m_object != nullptr`. */ - explicit iter_impl(pointer object) noexcept : m_object(object) + explicit iter_impl(pointer object) noexcept + : m_object(object) { JSON_ASSERT(m_object != nullptr); @@ -148,7 +148,8 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci information refer to: https://github.com/nlohmann/json/issues/1608 */ iter_impl(const iter_impl& other) noexcept - : m_object(other.m_object), m_it(other.m_it) + : m_object(other.m_object) + , m_it(other.m_it) {} /*! @@ -173,7 +174,8 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci @note It is not checked whether @a other is initialized. */ iter_impl(const iter_impl::type>& other) noexcept - : m_object(other.m_object), m_it(other.m_it) + : m_object(other.m_object) + , m_it(other.m_it) {} /*! @@ -182,14 +184,14 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci @return const/non-const iterator @note It is not checked whether @a other is initialized. */ - iter_impl& operator=(const iter_impl::type>& other) noexcept // NOLINT(cert-oop54-cpp) + iter_impl& operator=(const iter_impl::type>& other) noexcept // NOLINT(cert-oop54-cpp) { m_object = other.m_object; m_it = other.m_it; return *this; } - JSON_PRIVATE_UNLESS_TESTED: + JSON_PRIVATE_UNLESS_TESTED : /*! @brief set the iterator to the first value @pre The iterator is initialized; i.e. `m_object != nullptr`. @@ -363,7 +365,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci @brief post-increment (it++) @pre The iterator is initialized; i.e. `m_object != nullptr`. */ - iter_impl operator++(int)& // NOLINT(cert-dcl21-cpp) + iter_impl operator++(int) & // NOLINT(cert-dcl21-cpp) { auto result = *this; ++(*this); @@ -414,7 +416,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci @brief post-decrement (it--) @pre The iterator is initialized; i.e. `m_object != nullptr`. */ - iter_impl operator--(int)& // NOLINT(cert-dcl21-cpp) + iter_impl operator--(int) & // NOLINT(cert-dcl21-cpp) { auto result = *this; --(*this); @@ -465,7 +467,8 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci @brief comparison: equal @pre The iterator is initialized; i.e. `m_object != nullptr`. */ - template < typename IterImpl, detail::enable_if_t < (std::is_same::value || std::is_same::value), std::nullptr_t > = nullptr > + template::value || std::is_same::value), std::nullptr_t> = nullptr> bool operator==(const IterImpl& other) const { // if objects are not the same, the comparison is undefined @@ -501,7 +504,8 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci @brief comparison: not equal @pre The iterator is initialized; i.e. `m_object != nullptr`. */ - template < typename IterImpl, detail::enable_if_t < (std::is_same::value || std::is_same::value), std::nullptr_t > = nullptr > + template::value || std::is_same::value), std::nullptr_t> = nullptr> bool operator!=(const IterImpl& other) const { return !operator==(other); @@ -548,7 +552,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci */ bool operator<=(const iter_impl& other) const { - return !other.operator < (*this); + return !other.operator<(*this); } /*! @@ -740,11 +744,11 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci return operator*(); } - JSON_PRIVATE_UNLESS_TESTED: + JSON_PRIVATE_UNLESS_TESTED : /// associated JSON instance pointer m_object = nullptr; /// the actual iterator of the associated instance - internal_iterator::type> m_it {}; + internal_iterator::type> m_it{}; }; } // namespace detail diff --git a/include/nlohmann/detail/iterators/iteration_proxy.hpp b/include/nlohmann/detail/iterators/iteration_proxy.hpp index 76293de227..090cc9ca37 100644 --- a/include/nlohmann/detail/iterators/iteration_proxy.hpp +++ b/include/nlohmann/detail/iterators/iteration_proxy.hpp @@ -8,14 +8,14 @@ #pragma once -#include // size_t -#include // input_iterator_tag -#include // string, to_string -#include // tuple_size, get, tuple_element -#include // move +#include // size_t +#include // input_iterator_tag +#include // string, to_string +#include // tuple_size, get, tuple_element +#include // move #if JSON_HAS_RANGES - #include // enable_borrowed_range + #include // enable_borrowed_range #endif #include @@ -27,21 +27,22 @@ namespace detail { template -void int_to_string( string_type& target, std::size_t value ) +void int_to_string(string_type& target, std::size_t value) { // For ADL using std::to_string; target = to_string(value); } -template class iteration_proxy_value +template +class iteration_proxy_value { public: using difference_type = std::ptrdiff_t; using value_type = iteration_proxy_value; - using pointer = value_type *; - using reference = value_type &; + using pointer = value_type*; + using reference = value_type&; using iterator_category = std::input_iterator_tag; - using string_type = typename std::remove_cv< typename std::remove_reference().key() ) >::type >::type; + using string_type = typename std::remove_cv().key())>::type>::type; private: /// the iterator @@ -57,22 +58,21 @@ template class iteration_proxy_value public: explicit iteration_proxy_value() = default; - explicit iteration_proxy_value(IteratorType it, std::size_t array_index_ = 0) - noexcept(std::is_nothrow_move_constructible::value - && std::is_nothrow_default_constructible::value) - : anchor(std::move(it)) - , array_index(array_index_) + explicit iteration_proxy_value(IteratorType it, std::size_t array_index_ = 0) noexcept(std::is_nothrow_move_constructible::value && + std::is_nothrow_default_constructible::value) + : anchor(std::move(it)) + , array_index(array_index_) {} iteration_proxy_value(iteration_proxy_value const&) = default; iteration_proxy_value& operator=(iteration_proxy_value const&) = default; // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions - iteration_proxy_value(iteration_proxy_value&&) - noexcept(std::is_nothrow_move_constructible::value - && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) - iteration_proxy_value& operator=(iteration_proxy_value&&) - noexcept(std::is_nothrow_move_assignable::value - && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) + iteration_proxy_value(iteration_proxy_value&&) noexcept(std::is_nothrow_move_constructible::value && + std::is_nothrow_move_constructible::value) = + default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) + iteration_proxy_value& operator=(iteration_proxy_value&&) noexcept(std::is_nothrow_move_assignable::value && + std::is_nothrow_move_assignable::value) = + default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) ~iteration_proxy_value() = default; /// dereference operator (needed for range-based for) @@ -90,7 +90,7 @@ template class iteration_proxy_value return *this; } - iteration_proxy_value operator++(int)& // NOLINT(cert-dcl21-cpp) + iteration_proxy_value operator++(int) & // NOLINT(cert-dcl21-cpp) { auto tmp = iteration_proxy_value(anchor, array_index); ++anchor; @@ -122,7 +122,7 @@ template class iteration_proxy_value { if (array_index != array_index_last) { - int_to_string( array_index_str, array_index ); + int_to_string(array_index_str, array_index); array_index_last = array_index; } return array_index_str; @@ -154,7 +154,8 @@ template class iteration_proxy_value }; /// proxy class for the items() function -template class iteration_proxy +template +class iteration_proxy { private: /// the container to iterate @@ -165,7 +166,8 @@ template class iteration_proxy /// construct iteration proxy from a container explicit iteration_proxy(typename IteratorType::reference cont) noexcept - : container(&cont) {} + : container(&cont) + {} iteration_proxy(iteration_proxy const&) = default; iteration_proxy& operator=(iteration_proxy const&) = default; @@ -219,16 +221,15 @@ namespace std #pragma clang diagnostic ignored "-Wmismatched-tags" #endif template -class tuple_size<::nlohmann::detail::iteration_proxy_value> // NOLINT(cert-dcl58-cpp) - : public std::integral_constant {}; +class tuple_size<::nlohmann::detail::iteration_proxy_value> // NOLINT(cert-dcl58-cpp) + : public std::integral_constant +{}; template -class tuple_element> // NOLINT(cert-dcl58-cpp) +class tuple_element> // NOLINT(cert-dcl58-cpp) { public: - using type = decltype( - get(std::declval < - ::nlohmann::detail::iteration_proxy_value> ())); + using type = decltype(get(std::declval<::nlohmann::detail::iteration_proxy_value>())); }; #if defined(__clang__) #pragma clang diagnostic pop @@ -237,6 +238,6 @@ class tuple_element> } // namespace std #if JSON_HAS_RANGES - template - inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy> = true; +template +inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy> = true; #endif diff --git a/include/nlohmann/detail/iterators/iterator_traits.hpp b/include/nlohmann/detail/iterators/iterator_traits.hpp index 84cc27a85e..6c85b0e3a9 100644 --- a/include/nlohmann/detail/iterators/iterator_traits.hpp +++ b/include/nlohmann/detail/iterators/iterator_traits.hpp @@ -8,24 +8,24 @@ #pragma once -#include // random_access_iterator_tag +#include // random_access_iterator_tag #include -#include #include +#include NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { template -struct iterator_types {}; +struct iterator_types +{}; template -struct iterator_types < +struct iterator_types< It, - void_t> + void_t> { using difference_type = typename It::difference_type; using value_type = typename It::value_type; @@ -38,14 +38,11 @@ struct iterator_types < // doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. template struct iterator_traits -{ -}; +{}; template -struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> - : iterator_types -{ -}; +struct iterator_traits::value>> : iterator_types +{}; template struct iterator_traits::value>> diff --git a/include/nlohmann/detail/iterators/json_reverse_iterator.hpp b/include/nlohmann/detail/iterators/json_reverse_iterator.hpp index 006d5499ad..1a99af2f11 100644 --- a/include/nlohmann/detail/iterators/json_reverse_iterator.hpp +++ b/include/nlohmann/detail/iterators/json_reverse_iterator.hpp @@ -8,9 +8,9 @@ #pragma once -#include // ptrdiff_t -#include // reverse_iterator -#include // declval +#include // ptrdiff_t +#include // reverse_iterator +#include // declval #include @@ -52,13 +52,16 @@ class json_reverse_iterator : public std::reverse_iterator /// create reverse iterator from iterator explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept - : base_iterator(it) {} + : base_iterator(it) + {} /// create reverse iterator from base class - explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {} + explicit json_reverse_iterator(const base_iterator& it) noexcept + : base_iterator(it) + {} /// post-increment (it++) - json_reverse_iterator operator++(int)& // NOLINT(cert-dcl21-cpp) + json_reverse_iterator operator++(int) & // NOLINT(cert-dcl21-cpp) { return static_cast(base_iterator::operator++(1)); } @@ -70,7 +73,7 @@ class json_reverse_iterator : public std::reverse_iterator } /// post-decrement (it--) - json_reverse_iterator operator--(int)& // NOLINT(cert-dcl21-cpp) + json_reverse_iterator operator--(int) & // NOLINT(cert-dcl21-cpp) { return static_cast(base_iterator::operator--(1)); } @@ -122,7 +125,7 @@ class json_reverse_iterator : public std::reverse_iterator reference value() const { auto it = --this->base(); - return it.operator * (); + return it.operator*(); } }; diff --git a/include/nlohmann/detail/iterators/primitive_iterator.hpp b/include/nlohmann/detail/iterators/primitive_iterator.hpp index 0b6e8499e6..ab82623c7b 100644 --- a/include/nlohmann/detail/iterators/primitive_iterator.hpp +++ b/include/nlohmann/detail/iterators/primitive_iterator.hpp @@ -8,8 +8,8 @@ #pragma once -#include // ptrdiff_t -#include // numeric_limits +#include // ptrdiff_t +#include // numeric_limits #include @@ -33,7 +33,7 @@ class primitive_iterator_t static constexpr difference_type begin_value = 0; static constexpr difference_type end_value = begin_value + 1; - JSON_PRIVATE_UNLESS_TESTED: + JSON_PRIVATE_UNLESS_TESTED : /// iterator as signed integer type difference_type m_it = (std::numeric_limits::min)(); @@ -95,7 +95,7 @@ class primitive_iterator_t return *this; } - primitive_iterator_t operator++(int)& noexcept // NOLINT(cert-dcl21-cpp) + primitive_iterator_t operator++(int) & noexcept // NOLINT(cert-dcl21-cpp) { auto result = *this; ++m_it; @@ -108,7 +108,7 @@ class primitive_iterator_t return *this; } - primitive_iterator_t operator--(int)& noexcept // NOLINT(cert-dcl21-cpp) + primitive_iterator_t operator--(int) & noexcept // NOLINT(cert-dcl21-cpp) { auto result = *this; --m_it; diff --git a/include/nlohmann/detail/json_custom_base_class.hpp b/include/nlohmann/detail/json_custom_base_class.hpp index d1e29162a3..4dd54cd9aa 100644 --- a/include/nlohmann/detail/json_custom_base_class.hpp +++ b/include/nlohmann/detail/json_custom_base_class.hpp @@ -8,7 +8,7 @@ #pragma once -#include // conditional, is_same +#include // conditional, is_same #include @@ -26,14 +26,11 @@ of @ref basic_json do not require complex case distinctions By default, this class is used because it is empty and thus has no effect on the behavior of @ref basic_json. */ -struct json_default_base {}; +struct json_default_base +{}; template -using json_base_class = typename std::conditional < - std::is_same::value, - json_default_base, - T - >::type; +using json_base_class = typename std::conditional::value, json_default_base, T>::type; } // namespace detail NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/json_pointer.hpp b/include/nlohmann/detail/json_pointer.hpp index 4fdcd9ad28..9b6e243e3e 100644 --- a/include/nlohmann/detail/json_pointer.hpp +++ b/include/nlohmann/detail/json_pointer.hpp @@ -8,18 +8,18 @@ #pragma once -#include // all_of -#include // isdigit -#include // errno, ERANGE -#include // strtoull +#include // all_of +#include // isdigit +#include // errno, ERANGE +#include // strtoull #ifndef JSON_NO_IO - #include // ostream -#endif // JSON_NO_IO -#include // max -#include // accumulate -#include // string -#include // move -#include // vector + #include // ostream +#endif // JSON_NO_IO +#include // max +#include // accumulate +#include // string +#include // move +#include // vector #include #include @@ -60,17 +60,14 @@ class json_pointer /// @brief create JSON pointer /// @sa https://json.nlohmann.me/api/json_pointer/json_pointer/ explicit json_pointer(const string_t& s = "") - : reference_tokens(split(s)) + : reference_tokens(split(s)) {} /// @brief return a string representation of the JSON pointer /// @sa https://json.nlohmann.me/api/json_pointer/to_string/ string_t to_string() const { - return std::accumulate(reference_tokens.begin(), reference_tokens.end(), - string_t{}, - [](const string_t& a, const string_t& b) - { + return std::accumulate(reference_tokens.begin(), reference_tokens.end(), string_t{}, [](const string_t& a, const string_t& b) { return detail::concat(a, '/', detail::escape(b)); }); } @@ -97,9 +94,7 @@ class json_pointer /// @sa https://json.nlohmann.me/api/json_pointer/operator_slasheq/ json_pointer& operator/=(const json_pointer& ptr) { - reference_tokens.insert(reference_tokens.end(), - ptr.reference_tokens.begin(), - ptr.reference_tokens.end()); + reference_tokens.insert(reference_tokens.end(), ptr.reference_tokens.begin(), ptr.reference_tokens.end()); return *this; } @@ -120,15 +115,14 @@ class json_pointer /// @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer /// @sa https://json.nlohmann.me/api/json_pointer/operator_slash/ - friend json_pointer operator/(const json_pointer& lhs, - const json_pointer& rhs) + friend json_pointer operator/(const json_pointer& lhs, const json_pointer& rhs) { return json_pointer(lhs) /= rhs; } /// @brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer /// @sa https://json.nlohmann.me/api/json_pointer/operator_slash/ - friend json_pointer operator/(const json_pointer& lhs, string_t token) // NOLINT(performance-unnecessary-value-param) + friend json_pointer operator/(const json_pointer& lhs, string_t token) // NOLINT(performance-unnecessary-value-param) { return json_pointer(lhs) /= std::move(token); } @@ -229,11 +223,11 @@ class json_pointer const char* p = s.c_str(); char* p_end = nullptr; - errno = 0; // strtoull doesn't reset errno - const unsigned long long res = std::strtoull(p, &p_end, 10); // NOLINT(runtime/int) - if (p == p_end // invalid input or empty string - || errno == ERANGE // out of range - || JSON_HEDLEY_UNLIKELY(static_cast(p_end - p) != s.size())) // incomplete read + errno = 0; // strtoull doesn't reset errno + const unsigned long long res = std::strtoull(p, &p_end, 10); // NOLINT(runtime/int) + if (p == p_end // invalid input or empty string + || errno == ERANGE // out of range + || JSON_HEDLEY_UNLIKELY(static_cast(p_end - p) != s.size())) // incomplete read { JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", s, "'"), nullptr)); } @@ -242,13 +236,13 @@ class json_pointer // https://github.com/nlohmann/json/pull/2203 if (res >= static_cast((std::numeric_limits::max)())) // NOLINT(runtime/int) { - JSON_THROW(detail::out_of_range::create(410, detail::concat("array index ", s, " exceeds size_type"), nullptr)); // LCOV_EXCL_LINE + JSON_THROW(detail::out_of_range::create(410, detail::concat("array index ", s, " exceeds size_type"), nullptr)); // LCOV_EXCL_LINE } return static_cast(res); } - JSON_PRIVATE_UNLESS_TESTED: + JSON_PRIVATE_UNLESS_TESTED : json_pointer top() const { if (JSON_HEDLEY_UNLIKELY(empty())) @@ -257,7 +251,7 @@ class json_pointer } json_pointer result = *this; - result.reference_tokens = {reference_tokens[0]}; + result.reference_tokens = { reference_tokens[0] }; return result; } @@ -359,17 +353,12 @@ class json_pointer if (ptr->is_null()) { // check if reference token is a number - const bool nums = - std::all_of(reference_token.begin(), reference_token.end(), - [](const unsigned char x) - { + const bool nums = std::all_of(reference_token.begin(), reference_token.end(), [](const unsigned char x) { return std::isdigit(x); }); // change value to array for numbers or "-" or to object otherwise - *ptr = (nums || reference_token == "-") - ? detail::value_t::array - : detail::value_t::object; + *ptr = (nums || reference_token == "-") ? detail::value_t::array : detail::value_t::object; } switch (ptr->type()) @@ -437,9 +426,10 @@ class json_pointer if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, detail::concat( - "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), - ") is out of range"), ptr)); + JSON_THROW(detail::out_of_range::create( + 402, + detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), + ptr)); } // note: at performs range check @@ -495,7 +485,10 @@ class json_pointer if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" cannot be used for const access - JSON_THROW(detail::out_of_range::create(402, detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), ptr)); + JSON_THROW(detail::out_of_range::create( + 402, + detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), + ptr)); } // use unchecked array access @@ -544,9 +537,10 @@ class json_pointer if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, detail::concat( - "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), - ") is out of range"), ptr)); + JSON_THROW(detail::out_of_range::create( + 402, + detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), + ptr)); } // note: at performs range check @@ -676,7 +670,8 @@ class json_pointer // check if nonempty reference string begins with slash if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) { - JSON_THROW(detail::parse_error::create(107, 1, detail::concat("JSON pointer must be empty or begin with '/' - was: '", reference_string, "'"), nullptr)); + JSON_THROW( + detail::parse_error::create(107, 1, detail::concat("JSON pointer must be empty or begin with '/' - was: '", reference_string, "'"), nullptr)); } // extract the reference tokens: @@ -685,14 +680,14 @@ class json_pointer for ( // search for the first slash after the first character std::size_t slash = reference_string.find_first_of('/', 1), - // set the beginning of the first reference token + // set the beginning of the first reference token start = 1; // we can stop if start == 0 (if slash == string_t::npos) start != 0; // set the beginning of the next reference token // (will eventually be 0 if slash == string_t::npos) start = (slash == string_t::npos) ? 0 : slash + 1, - // find next slash + // find next slash slash = reference_string.find_first_of('/', start)) { // use the text between the beginning of the reference token @@ -700,16 +695,12 @@ class json_pointer auto reference_token = reference_string.substr(start, slash - start); // check reference tokens are properly escaped - for (std::size_t pos = reference_token.find_first_of('~'); - pos != string_t::npos; - pos = reference_token.find_first_of('~', pos + 1)) + for (std::size_t pos = reference_token.find_first_of('~'); pos != string_t::npos; pos = reference_token.find_first_of('~', pos + 1)) { JSON_ASSERT(reference_token[pos] == '~'); // ~ must be followed by 0 or 1 - if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 || - (reference_token[pos + 1] != '0' && - reference_token[pos + 1] != '1'))) + if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 || (reference_token[pos + 1] != '0' && reference_token[pos + 1] != '1'))) { JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'", nullptr)); } @@ -732,9 +723,7 @@ class json_pointer @note Empty objects or arrays are flattened to `null`. */ template - static void flatten(const string_t& reference_string, - const BasicJsonType& value, - BasicJsonType& result) + static void flatten(const string_t& reference_string, const BasicJsonType& value, BasicJsonType& result) { switch (value.type()) { @@ -750,8 +739,7 @@ class json_pointer // iterate array and use index as reference string for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i) { - flatten(detail::concat(reference_string, '/', std::to_string(i)), - value.m_data.m_value.array->operator[](i), result); + flatten(detail::concat(reference_string, '/', std::to_string(i)), value.m_data.m_value.array->operator[](i), result); } } break; @@ -803,8 +791,7 @@ class json_pointer @throw type_error.313 if value cannot be unflattened */ template - static BasicJsonType - unflatten(const BasicJsonType& value) + static BasicJsonType unflatten(const BasicJsonType& value) { if (JSON_HEDLEY_UNLIKELY(!value.is_object())) { @@ -839,7 +826,7 @@ class json_pointer return result; } - json_pointer convert()&& + json_pointer convert() && { json_pointer result; result.reference_tokens = std::move(reference_tokens); @@ -866,58 +853,51 @@ class json_pointer /// @brief 3-way compares two JSON pointers template - std::strong_ordering operator<=>(const json_pointer& rhs) const noexcept // *NOPAD* + std::strong_ordering operator<=>(const json_pointer& rhs) const noexcept // *NOPAD* { - return reference_tokens <=> rhs.reference_tokens; // *NOPAD* + return reference_tokens <=> rhs.reference_tokens; // *NOPAD* } #else /// @brief compares two JSON pointers for equality /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator==(const json_pointer& lhs, - const json_pointer& rhs) noexcept; + friend bool operator==(const json_pointer& lhs, const json_pointer& rhs) noexcept; /// @brief compares JSON pointer and string for equality /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator==(const json_pointer& lhs, - const StringType& rhs); + friend bool operator==(const json_pointer& lhs, const StringType& rhs); /// @brief compares string and JSON pointer for equality /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator==(const StringType& lhs, - const json_pointer& rhs); + friend bool operator==(const StringType& lhs, const json_pointer& rhs); /// @brief compares two JSON pointers for inequality /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator!=(const json_pointer& lhs, - const json_pointer& rhs) noexcept; + friend bool operator!=(const json_pointer& lhs, const json_pointer& rhs) noexcept; /// @brief compares JSON pointer and string for inequality /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator!=(const json_pointer& lhs, - const StringType& rhs); + friend bool operator!=(const json_pointer& lhs, const StringType& rhs); /// @brief compares string and JSON pointer for inequality /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator!=(const StringType& lhs, - const json_pointer& rhs); + friend bool operator!=(const StringType& lhs, const json_pointer& rhs); /// @brief compares two JSON pointer for less-than template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator<(const json_pointer& lhs, - const json_pointer& rhs) noexcept; + friend bool operator<(const json_pointer& lhs, const json_pointer& rhs) noexcept; #endif private: @@ -928,58 +908,47 @@ class json_pointer #if !JSON_HAS_THREE_WAY_COMPARISON // functions cannot be defined inside class due to ODR violations template -inline bool operator==(const json_pointer& lhs, - const json_pointer& rhs) noexcept +inline bool operator==(const json_pointer& lhs, const json_pointer& rhs) noexcept { return lhs.reference_tokens == rhs.reference_tokens; } -template::string_t> +template::string_t> JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) -inline bool operator==(const json_pointer& lhs, - const StringType& rhs) +inline bool operator==(const json_pointer& lhs, const StringType& rhs) { return lhs == json_pointer(rhs); } -template::string_t> +template::string_t> JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) -inline bool operator==(const StringType& lhs, - const json_pointer& rhs) +inline bool operator==(const StringType& lhs, const json_pointer& rhs) { return json_pointer(lhs) == rhs; } template -inline bool operator!=(const json_pointer& lhs, - const json_pointer& rhs) noexcept +inline bool operator!=(const json_pointer& lhs, const json_pointer& rhs) noexcept { return !(lhs == rhs); } -template::string_t> +template::string_t> JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer)) -inline bool operator!=(const json_pointer& lhs, - const StringType& rhs) +inline bool operator!=(const json_pointer& lhs, const StringType& rhs) { return !(lhs == rhs); } -template::string_t> +template::string_t> JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer)) -inline bool operator!=(const StringType& lhs, - const json_pointer& rhs) +inline bool operator!=(const StringType& lhs, const json_pointer& rhs) { return !(lhs == rhs); } template -inline bool operator<(const json_pointer& lhs, - const json_pointer& rhs) noexcept +inline bool operator<(const json_pointer& lhs, const json_pointer& rhs) noexcept { return lhs.reference_tokens < rhs.reference_tokens; } diff --git a/include/nlohmann/detail/json_ref.hpp b/include/nlohmann/detail/json_ref.hpp index b8bb6a76b0..aea5e334fa 100644 --- a/include/nlohmann/detail/json_ref.hpp +++ b/include/nlohmann/detail/json_ref.hpp @@ -25,22 +25,20 @@ class json_ref using value_type = BasicJsonType; json_ref(value_type&& value) - : owned_value(std::move(value)) + : owned_value(std::move(value)) {} json_ref(const value_type& value) - : value_ref(&value) + : value_ref(&value) {} json_ref(std::initializer_list init) - : owned_value(init) + : owned_value(init) {} - template < - class... Args, - enable_if_t::value, int> = 0 > - json_ref(Args && ... args) - : owned_value(std::forward(args)...) + template::value, int> = 0> + json_ref(Args&&... args) + : owned_value(std::forward(args)...) {} // class should be movable only @@ -66,7 +64,7 @@ class json_ref value_type const* operator->() const { - return &** this; + return &**this; } private: diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 97127a6462..dac07dfbf4 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -8,7 +8,7 @@ #pragma once -#include // declval, pair +#include // declval, pair #include #include @@ -37,7 +37,7 @@ #define JSON_HAS_CPP_20 #define JSON_HAS_CPP_17 #define JSON_HAS_CPP_14 - #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 #define JSON_HAS_CPP_17 #define JSON_HAS_CPP_14 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) @@ -114,8 +114,8 @@ #endif #ifndef JSON_HAS_THREE_WAY_COMPARISON - #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \ - && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L + #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L && defined(__cpp_lib_three_way_comparison) && \ + __cpp_lib_three_way_comparison >= 201907L #define JSON_HAS_THREE_WAY_COMPARISON 1 #else #define JSON_HAS_THREE_WAY_COMPARISON 0 @@ -164,14 +164,14 @@ #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception #define JSON_TRY try - #define JSON_CATCH(exception) catch(exception) - #define JSON_INTERNAL_CATCH(exception) catch(exception) + #define JSON_CATCH(exception) catch (exception) + #define JSON_INTERNAL_CATCH(exception) catch (exception) #else #include #define JSON_THROW(exception) std::abort() - #define JSON_TRY if(true) - #define JSON_CATCH(exception) if(false) - #define JSON_INTERNAL_CATCH(exception) if(false) + #define JSON_TRY if (true) + #define JSON_CATCH(exception) if (false) + #define JSON_INTERNAL_CATCH(exception) if (false) #endif // override exception macros @@ -196,7 +196,7 @@ // allow overriding assert #if !defined(JSON_ASSERT) - #include // assert + #include // assert #define JSON_ASSERT(x) assert(x) #endif @@ -212,119 +212,196 @@ @def NLOHMANN_JSON_SERIALIZE_ENUM @since version 3.4.0 */ -#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ - template \ - inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [e](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.first == e; \ - }); \ - j = ((it != std::end(m)) ? it : std::begin(m))->second; \ - } \ - template \ - inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [&j](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.second == j; \ - }); \ - e = ((it != std::end(m)) ? it : std::begin(m))->first; \ +#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ + template \ + inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), [e](const std::pair& ej_pair) -> bool { \ + return ej_pair.first == e; \ + }); \ + j = ((it != std::end(m)) ? it : std::begin(m))->second; \ + } \ + template \ + inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), [&j](const std::pair& ej_pair) -> bool { \ + return ej_pair.second == j; \ + }); \ + e = ((it != std::end(m)) ? it : std::begin(m))->first; \ } // Ugly macros to avoid uglier copy-paste when specializing basic_json. They // may be removed in the future once the class is split. -#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ - template class ObjectType, \ - template class ArrayType, \ - class StringType, class BooleanType, class NumberIntegerType, \ - class NumberUnsignedType, class NumberFloatType, \ - template class AllocatorType, \ - template class JSONSerializer, \ - class BinaryType, \ +#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ + template class ObjectType, \ + template \ + class ArrayType, \ + class StringType, \ + class BooleanType, \ + class NumberIntegerType, \ + class NumberUnsignedType, \ + class NumberFloatType, \ + template \ + class AllocatorType, \ + template \ + class JSONSerializer, \ + class BinaryType, \ class CustomBaseClass> -#define NLOHMANN_BASIC_JSON_TPL \ - basic_json +#define NLOHMANN_BASIC_JSON_TPL \ + basic_json // Macros to simplify conversion from/to types -#define NLOHMANN_JSON_EXPAND( x ) x -#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME -#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ - NLOHMANN_JSON_PASTE64, \ - NLOHMANN_JSON_PASTE63, \ - NLOHMANN_JSON_PASTE62, \ - NLOHMANN_JSON_PASTE61, \ - NLOHMANN_JSON_PASTE60, \ - NLOHMANN_JSON_PASTE59, \ - NLOHMANN_JSON_PASTE58, \ - NLOHMANN_JSON_PASTE57, \ - NLOHMANN_JSON_PASTE56, \ - NLOHMANN_JSON_PASTE55, \ - NLOHMANN_JSON_PASTE54, \ - NLOHMANN_JSON_PASTE53, \ - NLOHMANN_JSON_PASTE52, \ - NLOHMANN_JSON_PASTE51, \ - NLOHMANN_JSON_PASTE50, \ - NLOHMANN_JSON_PASTE49, \ - NLOHMANN_JSON_PASTE48, \ - NLOHMANN_JSON_PASTE47, \ - NLOHMANN_JSON_PASTE46, \ - NLOHMANN_JSON_PASTE45, \ - NLOHMANN_JSON_PASTE44, \ - NLOHMANN_JSON_PASTE43, \ - NLOHMANN_JSON_PASTE42, \ - NLOHMANN_JSON_PASTE41, \ - NLOHMANN_JSON_PASTE40, \ - NLOHMANN_JSON_PASTE39, \ - NLOHMANN_JSON_PASTE38, \ - NLOHMANN_JSON_PASTE37, \ - NLOHMANN_JSON_PASTE36, \ - NLOHMANN_JSON_PASTE35, \ - NLOHMANN_JSON_PASTE34, \ - NLOHMANN_JSON_PASTE33, \ - NLOHMANN_JSON_PASTE32, \ - NLOHMANN_JSON_PASTE31, \ - NLOHMANN_JSON_PASTE30, \ - NLOHMANN_JSON_PASTE29, \ - NLOHMANN_JSON_PASTE28, \ - NLOHMANN_JSON_PASTE27, \ - NLOHMANN_JSON_PASTE26, \ - NLOHMANN_JSON_PASTE25, \ - NLOHMANN_JSON_PASTE24, \ - NLOHMANN_JSON_PASTE23, \ - NLOHMANN_JSON_PASTE22, \ - NLOHMANN_JSON_PASTE21, \ - NLOHMANN_JSON_PASTE20, \ - NLOHMANN_JSON_PASTE19, \ - NLOHMANN_JSON_PASTE18, \ - NLOHMANN_JSON_PASTE17, \ - NLOHMANN_JSON_PASTE16, \ - NLOHMANN_JSON_PASTE15, \ - NLOHMANN_JSON_PASTE14, \ - NLOHMANN_JSON_PASTE13, \ - NLOHMANN_JSON_PASTE12, \ - NLOHMANN_JSON_PASTE11, \ - NLOHMANN_JSON_PASTE10, \ - NLOHMANN_JSON_PASTE9, \ - NLOHMANN_JSON_PASTE8, \ - NLOHMANN_JSON_PASTE7, \ - NLOHMANN_JSON_PASTE6, \ - NLOHMANN_JSON_PASTE5, \ - NLOHMANN_JSON_PASTE4, \ - NLOHMANN_JSON_PASTE3, \ - NLOHMANN_JSON_PASTE2, \ - NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) +#define NLOHMANN_JSON_EXPAND(x) x +#define NLOHMANN_JSON_GET_MACRO(_1, \ + _2, \ + _3, \ + _4, \ + _5, \ + _6, \ + _7, \ + _8, \ + _9, \ + _10, \ + _11, \ + _12, \ + _13, \ + _14, \ + _15, \ + _16, \ + _17, \ + _18, \ + _19, \ + _20, \ + _21, \ + _22, \ + _23, \ + _24, \ + _25, \ + _26, \ + _27, \ + _28, \ + _29, \ + _30, \ + _31, \ + _32, \ + _33, \ + _34, \ + _35, \ + _36, \ + _37, \ + _38, \ + _39, \ + _40, \ + _41, \ + _42, \ + _43, \ + _44, \ + _45, \ + _46, \ + _47, \ + _48, \ + _49, \ + _50, \ + _51, \ + _52, \ + _53, \ + _54, \ + _55, \ + _56, \ + _57, \ + _58, \ + _59, \ + _60, \ + _61, \ + _62, \ + _63, \ + _64, \ + NAME, \ + ...) \ + NAME +#define NLOHMANN_JSON_PASTE(...) \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ + NLOHMANN_JSON_PASTE64, \ + NLOHMANN_JSON_PASTE63, \ + NLOHMANN_JSON_PASTE62, \ + NLOHMANN_JSON_PASTE61, \ + NLOHMANN_JSON_PASTE60, \ + NLOHMANN_JSON_PASTE59, \ + NLOHMANN_JSON_PASTE58, \ + NLOHMANN_JSON_PASTE57, \ + NLOHMANN_JSON_PASTE56, \ + NLOHMANN_JSON_PASTE55, \ + NLOHMANN_JSON_PASTE54, \ + NLOHMANN_JSON_PASTE53, \ + NLOHMANN_JSON_PASTE52, \ + NLOHMANN_JSON_PASTE51, \ + NLOHMANN_JSON_PASTE50, \ + NLOHMANN_JSON_PASTE49, \ + NLOHMANN_JSON_PASTE48, \ + NLOHMANN_JSON_PASTE47, \ + NLOHMANN_JSON_PASTE46, \ + NLOHMANN_JSON_PASTE45, \ + NLOHMANN_JSON_PASTE44, \ + NLOHMANN_JSON_PASTE43, \ + NLOHMANN_JSON_PASTE42, \ + NLOHMANN_JSON_PASTE41, \ + NLOHMANN_JSON_PASTE40, \ + NLOHMANN_JSON_PASTE39, \ + NLOHMANN_JSON_PASTE38, \ + NLOHMANN_JSON_PASTE37, \ + NLOHMANN_JSON_PASTE36, \ + NLOHMANN_JSON_PASTE35, \ + NLOHMANN_JSON_PASTE34, \ + NLOHMANN_JSON_PASTE33, \ + NLOHMANN_JSON_PASTE32, \ + NLOHMANN_JSON_PASTE31, \ + NLOHMANN_JSON_PASTE30, \ + NLOHMANN_JSON_PASTE29, \ + NLOHMANN_JSON_PASTE28, \ + NLOHMANN_JSON_PASTE27, \ + NLOHMANN_JSON_PASTE26, \ + NLOHMANN_JSON_PASTE25, \ + NLOHMANN_JSON_PASTE24, \ + NLOHMANN_JSON_PASTE23, \ + NLOHMANN_JSON_PASTE22, \ + NLOHMANN_JSON_PASTE21, \ + NLOHMANN_JSON_PASTE20, \ + NLOHMANN_JSON_PASTE19, \ + NLOHMANN_JSON_PASTE18, \ + NLOHMANN_JSON_PASTE17, \ + NLOHMANN_JSON_PASTE16, \ + NLOHMANN_JSON_PASTE15, \ + NLOHMANN_JSON_PASTE14, \ + NLOHMANN_JSON_PASTE13, \ + NLOHMANN_JSON_PASTE12, \ + NLOHMANN_JSON_PASTE11, \ + NLOHMANN_JSON_PASTE10, \ + NLOHMANN_JSON_PASTE9, \ + NLOHMANN_JSON_PASTE8, \ + NLOHMANN_JSON_PASTE7, \ + NLOHMANN_JSON_PASTE6, \ + NLOHMANN_JSON_PASTE5, \ + NLOHMANN_JSON_PASTE4, \ + NLOHMANN_JSON_PASTE3, \ + NLOHMANN_JSON_PASTE2, \ + NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) #define NLOHMANN_JSON_PASTE2(func, v1) func(v1) #define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) #define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) @@ -333,61 +410,3397 @@ #define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) #define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) #define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) -#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) -#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) -#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) -#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) -#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) -#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) -#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) -#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) -#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) -#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) -#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) -#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) -#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) -#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) -#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) -#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) -#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) -#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) -#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) -#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) -#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) -#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) -#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) -#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) -#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) -#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) -#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) -#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) -#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) -#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) -#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) -#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) -#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) -#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) -#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) -#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) -#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) -#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) -#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) -#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) -#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) -#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) -#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) -#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) -#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) -#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) -#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) -#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) -#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) -#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) +#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) +#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) +#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) +#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) +#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) +#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) +#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) +#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) +#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) +#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) +#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) +#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) +#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) +#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) +#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) +#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) +#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) +#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) +#define NLOHMANN_JSON_PASTE28(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) +#define NLOHMANN_JSON_PASTE29(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) +#define NLOHMANN_JSON_PASTE30(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE29(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29) +#define NLOHMANN_JSON_PASTE31(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE30(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30) +#define NLOHMANN_JSON_PASTE32(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE31(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31) +#define NLOHMANN_JSON_PASTE33(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE32(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32) +#define NLOHMANN_JSON_PASTE34(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE33(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33) +#define NLOHMANN_JSON_PASTE35(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE34(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34) +#define NLOHMANN_JSON_PASTE36(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE35(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35) +#define NLOHMANN_JSON_PASTE37(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE36(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36) +#define NLOHMANN_JSON_PASTE38(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE37(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37) +#define NLOHMANN_JSON_PASTE39(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE38(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38) +#define NLOHMANN_JSON_PASTE40(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE39(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39) +#define NLOHMANN_JSON_PASTE41(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE40(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40) +#define NLOHMANN_JSON_PASTE42(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE41(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41) +#define NLOHMANN_JSON_PASTE43(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE42(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42) +#define NLOHMANN_JSON_PASTE44(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE43(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43) +#define NLOHMANN_JSON_PASTE45(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE44(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44) +#define NLOHMANN_JSON_PASTE46(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE45(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45) +#define NLOHMANN_JSON_PASTE47(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE46(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46) +#define NLOHMANN_JSON_PASTE48(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE47(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47) +#define NLOHMANN_JSON_PASTE49(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE48(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48) +#define NLOHMANN_JSON_PASTE50(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE49(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49) +#define NLOHMANN_JSON_PASTE51(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE50(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50) +#define NLOHMANN_JSON_PASTE52(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE51(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51) +#define NLOHMANN_JSON_PASTE53(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE52(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52) +#define NLOHMANN_JSON_PASTE54(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE53(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53) +#define NLOHMANN_JSON_PASTE55(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE54(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54) +#define NLOHMANN_JSON_PASTE56(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE55(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55) +#define NLOHMANN_JSON_PASTE57(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE56(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56) +#define NLOHMANN_JSON_PASTE58(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE57(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57) +#define NLOHMANN_JSON_PASTE59(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE58(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58) +#define NLOHMANN_JSON_PASTE60(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE59(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59) +#define NLOHMANN_JSON_PASTE61(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE60(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60) +#define NLOHMANN_JSON_PASTE62(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE61(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61) +#define NLOHMANN_JSON_PASTE63(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61, \ + v62) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE62(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61, \ + v62) +#define NLOHMANN_JSON_PASTE64(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61, \ + v62, \ + v63) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE63(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61, \ + v62, \ + v63) #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); @@ -398,32 +3811,64 @@ @def NLOHMANN_DEFINE_TYPE_INTRUSIVE @since version 3.9.0 */ -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \ + } -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ + { \ + const Type nlohmann_json_default_obj{}; \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) \ + } -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } /*! @brief macro @def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE @since version 3.9.0 */ -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \ + } -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ + { \ + const Type nlohmann_json_default_obj{}; \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) \ + } // inspired from https://stackoverflow.com/a/26745591 // allows to call any std function as if (e.g. with begin): @@ -431,37 +3876,36 @@ // // it allows using the detected idiom to retrieve the return type // of such an expression -#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ - namespace detail { \ - using std::std_name; \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - } \ - \ - namespace detail2 { \ - struct std_name##_tag \ - { \ - }; \ - \ - template \ - std_name##_tag std_name(T&&...); \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - \ - template \ - struct would_call_std_##std_name \ - { \ - static constexpr auto const value = ::nlohmann::detail:: \ - is_detected_exact::value; \ - }; \ - } /* namespace detail2 */ \ - \ - template \ - struct would_call_std_##std_name : detail2::would_call_std_##std_name \ - { \ - } +#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ + namespace detail \ + { \ + using std::std_name; \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + } \ + \ + namespace detail2 \ + { \ + struct std_name##_tag \ + {}; \ + \ + template \ + std_name##_tag std_name(T&&...); \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + \ + template \ + struct would_call_std_##std_name \ + { \ + static constexpr auto const value = ::nlohmann::detail::is_detected_exact::value; \ + }; \ + } /* namespace detail2 */ \ + \ + template \ + struct would_call_std_##std_name : detail2::would_call_std_##std_name \ + {} #ifndef JSON_USE_IMPLICIT_CONVERSIONS #define JSON_USE_IMPLICIT_CONVERSIONS 1 diff --git a/include/nlohmann/detail/meta/cpp_future.hpp b/include/nlohmann/detail/meta/cpp_future.hpp index 412b5aa74b..b9f6f62db5 100644 --- a/include/nlohmann/detail/meta/cpp_future.hpp +++ b/include/nlohmann/detail/meta/cpp_future.hpp @@ -9,10 +9,10 @@ #pragma once -#include // array -#include // size_t -#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type -#include // index_sequence, make_index_sequence, index_sequence_for +#include // array +#include // size_t +#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type +#include // index_sequence, make_index_sequence, index_sequence_for #include @@ -28,8 +28,8 @@ using uncvref_t = typename std::remove_cv::typ // the following utilities are natively available in C++14 using std::enable_if_t; using std::index_sequence; -using std::make_index_sequence; using std::index_sequence_for; +using std::make_index_sequence; #else @@ -61,7 +61,7 @@ using enable_if_t = typename std::enable_if::type; // // will be deduced to `0, 1, 2, 3, 4`. // user_function(make_integer_sequence()); // } -template +template struct integer_sequence { using value_type = T; @@ -76,38 +76,37 @@ struct integer_sequence // A helper template for an `integer_sequence` of `size_t`, // `absl::index_sequence` is designed to be a drop-in replacement for C++14's // `std::index_sequence`. -template +template using index_sequence = integer_sequence; namespace utility_internal { -template +template struct Extend; // Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency. -template +template struct Extend, SeqSize, 0> { - using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >; + using type = integer_sequence; }; -template +template struct Extend, SeqSize, 1> { - using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >; + using type = integer_sequence; }; // Recursion helper for 'make_integer_sequence'. // 'Gen::type' is an alias for 'integer_sequence'. -template +template struct Gen { - using type = - typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type; + using type = typename Extend::type, N / 2, N % 2>::type; }; -template +template struct Gen { using type = integer_sequence; @@ -122,7 +121,7 @@ struct Gen // This template alias is equivalent to // `integer_sequence`, and is designed to be a drop-in // replacement for C++14's `std::make_integer_sequence`. -template +template using make_integer_sequence = typename utility_internal::Gen::type; // make_index_sequence @@ -130,7 +129,7 @@ using make_integer_sequence = typename utility_internal::Gen::type; // This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`, // and is designed to be a drop-in replacement for C++14's // `std::make_index_sequence`. -template +template using make_index_sequence = make_integer_sequence; // index_sequence_for @@ -138,7 +137,7 @@ using make_index_sequence = make_integer_sequence; // Converts a typename pack into an index sequence of the same length, and // is designed to be a drop-in replacement for C++14's // `std::index_sequence_for()` -template +template using index_sequence_for = make_index_sequence; //// END OF CODE FROM GOOGLE ABSEIL @@ -146,8 +145,12 @@ using index_sequence_for = make_index_sequence; #endif // dispatch utility (taken from ranges-v3) -template struct priority_tag : priority_tag < N - 1 > {}; -template<> struct priority_tag<0> {}; +template +struct priority_tag : priority_tag +{}; +template<> +struct priority_tag<0> +{}; // taken from ranges-v3 template @@ -157,14 +160,14 @@ struct static_const }; #ifndef JSON_HAS_CPP_17 - template - constexpr T static_const::value; +template +constexpr T static_const::value; #endif template -inline constexpr std::array make_array(Args&& ... args) +inline constexpr std::array make_array(Args&&... args) { - return std::array {{static_cast(std::forward(args))...}}; + return std::array{ { static_cast(std::forward(args))... } }; } } // namespace detail diff --git a/include/nlohmann/detail/meta/detected.hpp b/include/nlohmann/detail/meta/detected.hpp index 1db9bf9ca3..64882ac399 100644 --- a/include/nlohmann/detail/meta/detected.hpp +++ b/include/nlohmann/detail/meta/detected.hpp @@ -27,10 +27,7 @@ struct nonesuch void operator=(nonesuch&&) = delete; }; -template class Op, - class... Args> +template class Op, class... Args> struct detector { using value_t = std::false_type; @@ -48,7 +45,8 @@ template class Op, class... Args> using is_detected = typename detector::value_t; template class Op, class... Args> -struct is_detected_lazy : is_detected { }; +struct is_detected_lazy : is_detected +{}; template class Op, class... Args> using detected_t = typename detector::type; @@ -63,8 +61,7 @@ template class Op, class... Args> using is_detected_exact = std::is_same>; template class Op, class... Args> -using is_detected_convertible = - std::is_convertible, To>; +using is_detected_convertible = std::is_convertible, To>; } // namespace detail NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/identity_tag.hpp b/include/nlohmann/detail/meta/identity_tag.hpp index 269deffb26..963a94bff4 100644 --- a/include/nlohmann/detail/meta/identity_tag.hpp +++ b/include/nlohmann/detail/meta/identity_tag.hpp @@ -15,7 +15,9 @@ namespace detail { // dispatching helper struct -template struct identity_tag {}; +template +struct identity_tag +{}; } // namespace detail NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/is_sax.hpp b/include/nlohmann/detail/meta/is_sax.hpp index 4e02bc1480..9250170e66 100644 --- a/include/nlohmann/detail/meta/is_sax.hpp +++ b/include/nlohmann/detail/meta/is_sax.hpp @@ -8,9 +8,9 @@ #pragma once -#include // size_t -#include // declval -#include // string +#include // size_t +#include // string +#include // declval #include #include @@ -24,58 +24,47 @@ template using null_function_t = decltype(std::declval().null()); template -using boolean_function_t = - decltype(std::declval().boolean(std::declval())); +using boolean_function_t = decltype(std::declval().boolean(std::declval())); template -using number_integer_function_t = - decltype(std::declval().number_integer(std::declval())); +using number_integer_function_t = decltype(std::declval().number_integer(std::declval())); template -using number_unsigned_function_t = - decltype(std::declval().number_unsigned(std::declval())); +using number_unsigned_function_t = decltype(std::declval().number_unsigned(std::declval())); template -using number_float_function_t = decltype(std::declval().number_float( - std::declval(), std::declval())); +using number_float_function_t = decltype(std::declval().number_float(std::declval(), std::declval())); template -using string_function_t = - decltype(std::declval().string(std::declval())); +using string_function_t = decltype(std::declval().string(std::declval())); template -using binary_function_t = - decltype(std::declval().binary(std::declval())); +using binary_function_t = decltype(std::declval().binary(std::declval())); template -using start_object_function_t = - decltype(std::declval().start_object(std::declval())); +using start_object_function_t = decltype(std::declval().start_object(std::declval())); template -using key_function_t = - decltype(std::declval().key(std::declval())); +using key_function_t = decltype(std::declval().key(std::declval())); template using end_object_function_t = decltype(std::declval().end_object()); template -using start_array_function_t = - decltype(std::declval().start_array(std::declval())); +using start_array_function_t = decltype(std::declval().start_array(std::declval())); template using end_array_function_t = decltype(std::declval().end_array()); template -using parse_error_function_t = decltype(std::declval().parse_error( - std::declval(), std::declval(), - std::declval())); +using parse_error_function_t = + decltype(std::declval().parse_error(std::declval(), std::declval(), std::declval())); template struct is_sax { private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); + static_assert(is_basic_json::value, "BasicJsonType must be of type basic_json<...>"); using number_integer_t = typename BasicJsonType::number_integer_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t; @@ -86,27 +75,21 @@ struct is_sax public: static constexpr bool value = - is_detected_exact::value && - is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value && is_detected_exact::value && is_detected_exact::value && is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value; + is_detected_exact::value && is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value; }; template struct is_sax_static_asserts { private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); + static_assert(is_basic_json::value, "BasicJsonType must be of type basic_json<...>"); using number_integer_t = typename BasicJsonType::number_integer_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t; @@ -116,43 +99,25 @@ struct is_sax_static_asserts using exception_t = typename BasicJsonType::exception; public: - static_assert(is_detected_exact::value, - "Missing/invalid function: bool null()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_integer(number_integer_t)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); - static_assert(is_detected_exact::value, + static_assert(is_detected_exact::value, "Missing/invalid function: bool null()"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool boolean(bool)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool boolean(bool)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool number_integer(number_integer_t)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool number_float(number_float_t, const string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool string(string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool binary(binary_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_object(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool key(string_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_object()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_array(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_array()"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool parse_error(std::size_t, const " - "std::string&, const exception&)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool string(string_t&)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool binary(binary_t&)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool start_object(std::size_t)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool key(string_t&)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool end_object()"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool start_array(std::size_t)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool end_array()"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool parse_error(std::size_t, const " + "std::string&, const exception&)"); }; } // namespace detail diff --git a/include/nlohmann/detail/meta/std_fs.hpp b/include/nlohmann/detail/meta/std_fs.hpp index fd18039649..1d40745f49 100644 --- a/include/nlohmann/detail/meta/std_fs.hpp +++ b/include/nlohmann/detail/meta/std_fs.hpp @@ -11,7 +11,7 @@ #include #if JSON_HAS_EXPERIMENTAL_FILESYSTEM -#include + #include NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -19,7 +19,7 @@ namespace std_fs = std::experimental::filesystem; } // namespace detail NLOHMANN_JSON_NAMESPACE_END #elif JSON_HAS_FILESYSTEM -#include + #include NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp index e1b000dcc2..cbd9c1c4c2 100644 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ b/include/nlohmann/detail/meta/type_traits.hpp @@ -8,11 +8,11 @@ #pragma once -#include // numeric_limits -#include // false_type, is_constructible, is_integral, is_same, true_type -#include // declval -#include // tuple -#include // char_traits +#include // numeric_limits +#include // char_traits +#include // tuple +#include // false_type, is_constructible, is_integral, is_same, true_type +#include // declval #include #include @@ -47,19 +47,22 @@ namespace detail // In this case, T has to be properly CV-qualified to constraint the function arguments // (e.g. to_json(BasicJsonType&, const T&)) -template struct is_basic_json : std::false_type {}; +template +struct is_basic_json : std::false_type +{}; NLOHMANN_BASIC_JSON_TPL_DECLARATION -struct is_basic_json : std::true_type {}; +struct is_basic_json : std::true_type +{}; // used by exceptions create() member functions // true_type for pointer to possibly cv-qualified basic_json or std::nullptr_t // false_type otherwise template -struct is_basic_json_context : - std::integral_constant < bool, - is_basic_json::type>::type>::value - || std::is_same::value > +struct is_basic_json_context + : std::integral_constant::type>::type>::value || + std::is_same::value> {}; ////////////////////// @@ -70,10 +73,12 @@ template class json_ref; template -struct is_json_ref : std::false_type {}; +struct is_json_ref : std::false_type +{}; template -struct is_json_ref> : std::true_type {}; +struct is_json_ref> : std::true_type +{}; ////////////////////////// // aliases for detected // @@ -111,63 +116,61 @@ using get_template_function = decltype(std::declval().template get()); // trait checking if JSONSerializer::from_json(json const&, udt&) exists template -struct has_from_json : std::false_type {}; +struct has_from_json : std::false_type +{}; // trait checking if j.get is valid // use this trait instead of std::is_constructible or std::is_convertible, // both rely on, or make use of implicit conversions, and thus fail when T // has several constructors/operator= (see https://github.com/nlohmann/json/issues/958) -template +template struct is_getable { static constexpr bool value = is_detected::value; }; template -struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> +struct has_from_json::value>> { using serializer = typename BasicJsonType::template json_serializer; - static constexpr bool value = - is_detected_exact::value; + static constexpr bool value = is_detected_exact::value; }; // This trait checks if JSONSerializer::from_json(json const&) exists // this overload is used for non-default-constructible user-defined-types template -struct has_non_default_from_json : std::false_type {}; +struct has_non_default_from_json : std::false_type +{}; template -struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> +struct has_non_default_from_json::value>> { using serializer = typename BasicJsonType::template json_serializer; - static constexpr bool value = - is_detected_exact::value; + static constexpr bool value = is_detected_exact::value; }; // This trait checks if BasicJsonType::json_serializer::to_json exists // Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion. template -struct has_to_json : std::false_type {}; +struct has_to_json : std::false_type +{}; template -struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> +struct has_to_json::value>> { using serializer = typename BasicJsonType::template json_serializer; - static constexpr bool value = - is_detected_exact::value; + static constexpr bool value = is_detected_exact::value; }; template using detect_key_compare = typename T::key_compare; template -struct has_key_compare : std::integral_constant::value> {}; +struct has_key_compare : std::integral_constant::value> +{}; // obtains the actual object key comparator template @@ -175,8 +178,7 @@ struct actual_object_comparator { using object_t = typename BasicJsonType::object_t; using object_comparator_t = typename BasicJsonType::default_object_comparator_t; - using type = typename std::conditional < has_key_compare::value, - typename object_t::key_compare, object_comparator_t>::type; + using type = typename std::conditional::value, typename object_t::key_compare, object_comparator_t>::type; }; template @@ -244,54 +246,67 @@ struct char_traits : std::char_traits /////////////////// // https://en.cppreference.com/w/cpp/types/conjunction -template struct conjunction : std::true_type { }; -template struct conjunction : B { }; +template +struct conjunction : std::true_type +{}; +template +struct conjunction : B +{}; template -struct conjunction -: std::conditional(B::value), conjunction, B>::type {}; +struct conjunction : std::conditional(B::value), conjunction, B>::type +{}; // https://en.cppreference.com/w/cpp/types/negation -template struct negation : std::integral_constant < bool, !B::value > { }; +template +struct negation : std::integral_constant +{}; // Reimplementation of is_constructible and is_default_constructible, due to them being broken for // std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367). // This causes compile errors in e.g. clang 3.5 or gcc 4.9. -template -struct is_default_constructible : std::is_default_constructible {}; +template +struct is_default_constructible : std::is_default_constructible +{}; -template -struct is_default_constructible> - : conjunction, is_default_constructible> {}; +template +struct is_default_constructible> : conjunction, is_default_constructible> +{}; -template -struct is_default_constructible> - : conjunction, is_default_constructible> {}; +template +struct is_default_constructible> : conjunction, is_default_constructible> +{}; -template -struct is_default_constructible> - : conjunction...> {}; +template +struct is_default_constructible> : conjunction...> +{}; -template -struct is_default_constructible> - : conjunction...> {}; +template +struct is_default_constructible> : conjunction...> +{}; -template -struct is_constructible : std::is_constructible {}; +template +struct is_constructible : std::is_constructible +{}; -template -struct is_constructible> : is_default_constructible> {}; +template +struct is_constructible> : is_default_constructible> +{}; -template -struct is_constructible> : is_default_constructible> {}; +template +struct is_constructible> : is_default_constructible> +{}; -template -struct is_constructible> : is_default_constructible> {}; +template +struct is_constructible> : is_default_constructible> +{}; -template -struct is_constructible> : is_default_constructible> {}; +template +struct is_constructible> : is_default_constructible> +{}; template -struct is_iterator_traits : std::false_type {}; +struct is_iterator_traits : std::false_type +{}; template struct is_iterator_traits> @@ -300,12 +315,9 @@ struct is_iterator_traits> using traits = iterator_traits; public: - static constexpr auto value = - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value; + static constexpr auto value = is_detected::value && is_detected::value && + is_detected::value && is_detected::value && + is_detected::value; }; template @@ -320,8 +332,7 @@ struct is_range // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator // and https://en.cppreference.com/w/cpp/iterator/sentinel_for // but reimplementing these would be too much work, as a lot of other concepts are used underneath - static constexpr auto is_iterator_begin = - is_iterator_traits>::value; + static constexpr auto is_iterator_begin = is_iterator_traits>::value; public: static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; @@ -338,73 +349,62 @@ using range_value_t = value_type_t>>; // and is written by Xiang Fan who agreed to using it in this library. template -struct is_complete_type : std::false_type {}; +struct is_complete_type : std::false_type +{}; template -struct is_complete_type : std::true_type {}; +struct is_complete_type : std::true_type +{}; -template -struct is_compatible_object_type_impl : std::false_type {}; +template +struct is_compatible_object_type_impl : std::false_type +{}; template -struct is_compatible_object_type_impl < - BasicJsonType, CompatibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> +struct is_compatible_object_type_impl< + BasicJsonType, + CompatibleObjectType, + enable_if_t::value && is_detected::value>> { using object_t = typename BasicJsonType::object_t; // macOS's is_constructible does not play well with nonesuch... - static constexpr bool value = - is_constructible::value && - is_constructible::value; + static constexpr bool value = is_constructible::value && + is_constructible::value; }; template -struct is_compatible_object_type - : is_compatible_object_type_impl {}; +struct is_compatible_object_type : is_compatible_object_type_impl +{}; -template -struct is_constructible_object_type_impl : std::false_type {}; +template +struct is_constructible_object_type_impl : std::false_type +{}; template -struct is_constructible_object_type_impl < - BasicJsonType, ConstructibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> +struct is_constructible_object_type_impl< + BasicJsonType, + ConstructibleObjectType, + enable_if_t::value && is_detected::value>> { using object_t = typename BasicJsonType::object_t; - static constexpr bool value = - (is_default_constructible::value && - (std::is_move_assignable::value || - std::is_copy_assignable::value) && - (is_constructible::value && - std::is_same < - typename object_t::mapped_type, - typename ConstructibleObjectType::mapped_type >::value)) || - (has_from_json::value || - has_non_default_from_json < - BasicJsonType, - typename ConstructibleObjectType::mapped_type >::value); + static constexpr bool value = (is_default_constructible::value && + (std::is_move_assignable::value || std::is_copy_assignable::value) && + (is_constructible::value && + std::is_same::value)) || + (has_from_json::value || + has_non_default_from_json::value); }; template -struct is_constructible_object_type - : is_constructible_object_type_impl {}; +struct is_constructible_object_type : is_constructible_object_type_impl +{}; template struct is_compatible_string_type { - static constexpr auto value = - is_constructible::value; + static constexpr auto value = is_constructible::value; }; template @@ -417,174 +417,164 @@ struct is_constructible_string_type using laundered_type = ConstructibleStringType; #endif - static constexpr auto value = - conjunction < - is_constructible, - is_detected_exact>::value; + static constexpr auto value = conjunction, + is_detected_exact>::value; }; template -struct is_compatible_array_type_impl : std::false_type {}; +struct is_compatible_array_type_impl : std::false_type +{}; template -struct is_compatible_array_type_impl < - BasicJsonType, CompatibleArrayType, - enable_if_t < - is_detected::value&& - is_iterator_traits>>::value&& -// special case for types like std::filesystem::path whose iterator's value_type are themselves -// c.f. https://github.com/nlohmann/json/pull/3073 - !std::is_same>::value >> -{ - static constexpr bool value = - is_constructible>::value; +struct is_compatible_array_type_impl::value && + is_iterator_traits>>::value && + // special case for types like std::filesystem::path whose iterator's value_type are themselves + // c.f. https://github.com/nlohmann/json/pull/3073 + !std::is_same>::value>> +{ + static constexpr bool value = is_constructible>::value; }; template -struct is_compatible_array_type - : is_compatible_array_type_impl {}; +struct is_compatible_array_type : is_compatible_array_type_impl +{}; template -struct is_constructible_array_type_impl : std::false_type {}; +struct is_constructible_array_type_impl : std::false_type +{}; template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t::value >> - : std::true_type {}; +struct is_constructible_array_type_impl::value>> : std::true_type +{}; template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t < !std::is_same::value&& - !is_compatible_string_type::value&& - is_default_constructible::value&& -(std::is_move_assignable::value || - std::is_copy_assignable::value)&& -is_detected::value&& -is_iterator_traits>>::value&& -is_detected::value&& -// special case for types like std::filesystem::path whose iterator's value_type are themselves -// c.f. https://github.com/nlohmann/json/pull/3073 -!std::is_same>::value&& - is_complete_type < - detected_t>::value >> +struct is_constructible_array_type_impl< + BasicJsonType, + ConstructibleArrayType, + enable_if_t::value && + !is_compatible_string_type::value && is_default_constructible::value && + (std::is_move_assignable::value || std::is_copy_assignable::value) && + is_detected::value && + is_iterator_traits>>::value && + is_detected::value && + // special case for types like std::filesystem::path whose iterator's value_type are themselves + // c.f. https://github.com/nlohmann/json/pull/3073 + !std::is_same>::value && + is_complete_type>::value>> { using value_type = range_value_t; - static constexpr bool value = - std::is_same::value || - has_from_json::value || - has_non_default_from_json < - BasicJsonType, - value_type >::value; + static constexpr bool value = std::is_same::value || + has_from_json::value || has_non_default_from_json::value; }; template -struct is_constructible_array_type - : is_constructible_array_type_impl {}; +struct is_constructible_array_type : is_constructible_array_type_impl +{}; -template -struct is_compatible_integer_type_impl : std::false_type {}; +template +struct is_compatible_integer_type_impl : std::false_type +{}; template -struct is_compatible_integer_type_impl < - RealIntegerType, CompatibleNumberIntegerType, - enable_if_t < std::is_integral::value&& - std::is_integral::value&& - !std::is_same::value >> +struct is_compatible_integer_type_impl::value && std::is_integral::value && + !std::is_same::value>> { // is there an assert somewhere on overflows? using RealLimits = std::numeric_limits; using CompatibleLimits = std::numeric_limits; - static constexpr auto value = - is_constructible::value && - CompatibleLimits::is_integer && - RealLimits::is_signed == CompatibleLimits::is_signed; + static constexpr auto value = is_constructible::value && CompatibleLimits::is_integer && + RealLimits::is_signed == CompatibleLimits::is_signed; }; template -struct is_compatible_integer_type - : is_compatible_integer_type_impl {}; +struct is_compatible_integer_type : is_compatible_integer_type_impl +{}; template -struct is_compatible_type_impl: std::false_type {}; +struct is_compatible_type_impl : std::false_type +{}; template -struct is_compatible_type_impl < - BasicJsonType, CompatibleType, - enable_if_t::value >> +struct is_compatible_type_impl::value>> { - static constexpr bool value = - has_to_json::value; + static constexpr bool value = has_to_json::value; }; template -struct is_compatible_type - : is_compatible_type_impl {}; +struct is_compatible_type : is_compatible_type_impl +{}; template -struct is_constructible_tuple : std::false_type {}; +struct is_constructible_tuple : std::false_type +{}; template -struct is_constructible_tuple> : conjunction...> {}; +struct is_constructible_tuple> : conjunction...> +{}; template -struct is_json_iterator_of : std::false_type {}; +struct is_json_iterator_of : std::false_type +{}; template -struct is_json_iterator_of : std::true_type {}; +struct is_json_iterator_of : std::true_type +{}; template struct is_json_iterator_of : std::true_type {}; // checks if a given type T is a template specialization of Primary -template