Try amalgamate again.

There seems to be some issues or inconsistencies with the astyle
version 3.2.1 from the AUR versus 3.2.1-build from apt:
   * --squeeze-lines is not defined in the one from Arch, so I had to
     comment that one out in order to make the amalgamate step run.
   * A bunch of files are affected by the amalgamate, which does not
     seem right.
This commit is contained in:
Fredrik Sandhei 2023-10-09 18:30:11 +02:00
parent 828bac981a
commit ca407117ed
11 changed files with 683 additions and 640 deletions

View File

@ -115,7 +115,7 @@ class exception : public std::exception
}
auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
[](const std::string & a, const std::string & b)
[](const std::string& a, const std::string& b)
{
return concat(a, '/', detail::escape(b));
});

View File

@ -190,7 +190,7 @@ template<class...> struct conjunction : std::true_type { };
template<class B> struct conjunction<B> : B { };
template<class B, class... Bn>
struct conjunction<B, Bn...>
: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
// https://en.cppreference.com/w/cpp/types/negation
template<class B> struct negation : std::integral_constant < bool, !B::value > { };
@ -415,7 +415,7 @@ is_detected<range_value_t, ConstructibleArrayType>::value&&
!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
is_complete_type <
detected_t<range_value_t, ConstructibleArrayType >>::value >>
{
{
using value_type = range_value_t<ConstructibleArrayType>;
static constexpr bool value =
@ -426,7 +426,7 @@ is_detected<range_value_t, ConstructibleArrayType>::value&&
has_non_default_from_json <
BasicJsonType,
value_type >::value;
};
};
template<typename BasicJsonType, typename ConstructibleArrayType>
struct is_constructible_array_type
@ -509,7 +509,7 @@ template<typename Compare, typename A, typename B>
struct is_comparable<Compare, A, B, void_t<
decltype(std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
>> : std::true_type {};
>> : std::true_type {};
template<typename T>
using detect_is_transparent = typename T::is_transparent;

View File

@ -4701,7 +4701,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
// the valid JSON Patch operations
enum class patch_operations {add, remove, replace, move, copy, test, invalid};
const auto get_op = [](const std::string & op)
const auto get_op = [](const std::string& op)
{
if (op == "add")
{
@ -4838,8 +4838,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
for (const auto& val : json_patch)
{
// wrapper to get a value for an operation
const auto get_value = [&val](const std::string & op,
const std::string & member,
const auto get_value = [&val](const std::string& op,
const std::string& member,
bool string_type) -> basic_json &
{
// find value
@ -5216,14 +5216,14 @@ struct less< ::nlohmann::detail::value_t> // do not remove the space after '<',
*/
bool operator()(::nlohmann::detail::value_t lhs,
::nlohmann::detail::value_t rhs) const noexcept
{
{
#if JSON_HAS_THREE_WAY_COMPARISON
return std::is_lt(lhs <=> rhs); // *NOPAD*
#else
return ::nlohmann::detail::operator<(lhs, rhs);
#endif
}
};
}
};
// C++20 prohibit function specialization in the std namespace.
#ifndef JSON_HAS_CPP_20

View File

@ -27,7 +27,7 @@ NLOHMANN_JSON_NAMESPACE_BEGIN
template <class Key, class T, class IgnoredLess = std::less<Key>,
class Allocator = std::allocator<std::pair<const Key, T>>>
struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
{
{
using key_type = Key;
using mapped_type = T;
using Container = std::vector<std::pair<const Key, T>, Allocator>;
@ -43,16 +43,16 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
// Explicit constructors instead of `using Container::Container`
// otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4)
ordered_map() noexcept(noexcept(Container())) : Container{} {}
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {}
template <class It>
ordered_map(It first, It last, const Allocator& alloc = Allocator())
: Container{first, last, alloc} {}
ordered_map(std::initializer_list<value_type> init, const Allocator& alloc = Allocator() )
: Container{init, alloc} {}
ordered_map() noexcept(noexcept(Container())) : Container{} {}
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {}
template <class It>
ordered_map(It first, It last, const Allocator& alloc = Allocator())
: Container{first, last, alloc} {}
ordered_map(std::initializer_list<value_type> init, const Allocator& alloc = Allocator() )
: Container{init, alloc} {}
std::pair<iterator, bool> emplace(const key_type& key, T&& t)
{
std::pair<iterator, bool> emplace(const key_type& key, T&& t)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -62,12 +62,12 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
Container::emplace_back(key, std::forward<T>(t));
return {std::prev(this->end()), true};
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
std::pair<iterator, bool> emplace(KeyType && key, T && t)
{
std::pair<iterator, bool> emplace(KeyType && key, T && t)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -77,34 +77,34 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
return {std::prev(this->end()), true};
}
}
T& operator[](const key_type& key)
{
T& operator[](const key_type& key)
{
return emplace(key, T{}).first->second;
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
T & operator[](KeyType && key)
{
T & operator[](KeyType && key)
{
return emplace(std::forward<KeyType>(key), T{}).first->second;
}
}
const T& operator[](const key_type& key) const
{
const T& operator[](const key_type& key) const
{
return at(key);
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
const T & operator[](KeyType && key) const
{
const T & operator[](KeyType && key) const
{
return at(std::forward<KeyType>(key));
}
}
T& at(const key_type& key)
{
T& at(const key_type& key)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -114,12 +114,12 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
JSON_THROW(std::out_of_range("key not found"));
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{
T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -129,10 +129,10 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
JSON_THROW(std::out_of_range("key not found"));
}
}
const T& at(const key_type& key) const
{
const T& at(const key_type& key) const
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -142,12 +142,12 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
JSON_THROW(std::out_of_range("key not found"));
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
{
const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -157,10 +157,10 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
JSON_THROW(std::out_of_range("key not found"));
}
}
size_type erase(const key_type& key)
{
size_type erase(const key_type& key)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -176,12 +176,12 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return 0;
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{
size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -197,15 +197,15 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return 0;
}
}
iterator erase(iterator pos)
{
iterator erase(iterator pos)
{
return erase(pos, std::next(pos));
}
}
iterator erase(iterator first, iterator last)
{
iterator erase(iterator first, iterator last)
{
if (first == last)
{
return first;
@ -255,10 +255,10 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
// use this iterator, because it may have been invalidated by the
// resize call. Instead, we can return begin() + offset.
return Container::begin() + offset;
}
}
size_type count(const key_type& key) const
{
size_type count(const key_type& key) const
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -267,12 +267,12 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return 0;
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
{
size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -281,10 +281,10 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return 0;
}
}
iterator find(const key_type& key)
{
iterator find(const key_type& key)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -293,12 +293,12 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return Container::end();
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{
iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -307,10 +307,10 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return Container::end();
}
}
const_iterator find(const key_type& key) const
{
const_iterator find(const key_type& key) const
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -319,15 +319,15 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return Container::end();
}
}
std::pair<iterator, bool> insert( value_type&& value )
{
std::pair<iterator, bool> insert( value_type&& value )
{
return emplace(value.first, std::move(value.second));
}
}
std::pair<iterator, bool> insert( const value_type& value )
{
std::pair<iterator, bool> insert( const value_type& value )
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, value.first))
@ -337,23 +337,23 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
Container::push_back(value);
return {--this->end(), true};
}
}
template<typename InputIt>
using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
template<typename InputIt>
using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
std::input_iterator_tag>::value>::type;
template<typename InputIt, typename = require_input_iter<InputIt>>
void insert(InputIt first, InputIt last)
{
template<typename InputIt, typename = require_input_iter<InputIt>>
void insert(InputIt first, InputIt last)
{
for (auto it = first; it != last; ++it)
{
insert(*it);
}
}
}
private:
JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare();
};
JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare();
};
NLOHMANN_JSON_NAMESPACE_END

View File

@ -41,6 +41,7 @@
// SPDX-License-Identifier: MIT
#include <utility>
// #include <nlohmann/detail/abi_macros.hpp>
@ -53,6 +54,7 @@
// SPDX-License-Identifier: MIT
// This file contains all macro definitions affecting or depending on the ABI
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
@ -154,6 +156,7 @@
// SPDX-License-Identifier: MIT
#include <algorithm> // transform
#include <array> // array
#include <forward_list> // forward_list
@ -176,6 +179,7 @@
// SPDX-License-Identifier: MIT
#include <cstddef> // nullptr_t
#include <exception> // exception
#if JSON_DIAGNOSTICS
@ -195,6 +199,7 @@
// SPDX-License-Identifier: MIT
#include <array> // array
#include <cstddef> // size_t
#include <cstdint> // uint8_t
@ -210,6 +215,7 @@
// SPDX-License-Identifier: MIT
#include <utility> // declval, pair
// #include <nlohmann/detail/meta/detected.hpp>
// __ _____ _____ _____
@ -221,6 +227,7 @@
// SPDX-License-Identifier: MIT
#include <type_traits>
// #include <nlohmann/detail/meta/void_t.hpp>
@ -233,6 +240,7 @@
// SPDX-License-Identifier: MIT
// #include <nlohmann/detail/abi_macros.hpp>
@ -2932,6 +2940,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
// #include <nlohmann/detail/abi_macros.hpp>
@ -3006,6 +3015,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <cstddef> // size_t
// #include <nlohmann/detail/abi_macros.hpp>
@ -3048,6 +3058,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <array> // array
#include <cstddef> // size_t
#include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
@ -3220,6 +3231,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <limits> // numeric_limits
#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
#include <utility> // declval
@ -3235,6 +3247,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <iterator> // random_access_iterator_tag
// #include <nlohmann/detail/abi_macros.hpp>
@ -3302,6 +3315,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
// #include <nlohmann/detail/macro_scope.hpp>
@ -3321,6 +3335,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
// #include <nlohmann/detail/macro_scope.hpp>
@ -3582,7 +3597,7 @@ template<class...> struct conjunction : std::true_type { };
template<class B> struct conjunction<B> : B { };
template<class B, class... Bn>
struct conjunction<B, Bn...>
: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
// https://en.cppreference.com/w/cpp/types/negation
template<class B> struct negation : std::integral_constant < bool, !B::value > { };
@ -3807,7 +3822,7 @@ is_detected<range_value_t, ConstructibleArrayType>::value&&
!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
is_complete_type <
detected_t<range_value_t, ConstructibleArrayType >>::value >>
{
{
using value_type = range_value_t<ConstructibleArrayType>;
static constexpr bool value =
@ -3818,7 +3833,7 @@ is_detected<range_value_t, ConstructibleArrayType>::value&&
has_non_default_from_json <
BasicJsonType,
value_type >::value;
};
};
template<typename BasicJsonType, typename ConstructibleArrayType>
struct is_constructible_array_type
@ -3901,7 +3916,7 @@ template<typename Compare, typename A, typename B>
struct is_comparable<Compare, A, B, void_t<
decltype(std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
>> : std::true_type {};
>> : std::true_type {};
template<typename T>
using detect_is_transparent = typename T::is_transparent;
@ -4143,6 +4158,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <cstring> // strlen
#include <string> // string
#include <utility> // forward
@ -4373,7 +4389,7 @@ class exception : public std::exception
}
auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
[](const std::string & a, const std::string & b)
[](const std::string& a, const std::string& b)
{
return concat(a, '/', detail::escape(b));
});
@ -4528,6 +4544,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
// #include <nlohmann/detail/abi_macros.hpp>
@ -4551,6 +4568,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
// #include <nlohmann/detail/macro_scope.hpp>
@ -5056,6 +5074,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <algorithm> // copy
#include <iterator> // begin, end
#include <string> // string
@ -5075,6 +5094,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <cstddef> // size_t
#include <iterator> // input_iterator_tag
#include <string> // string, to_string
@ -5795,6 +5815,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <cstdint> // uint8_t, uint64_t
#include <tuple> // tie
#include <utility> // move
@ -5906,6 +5927,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <cstdint> // uint8_t
#include <cstddef> // size_t
#include <functional> // hash
@ -6038,6 +6060,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <algorithm> // generate_n
#include <array> // array
#include <cmath> // ldexp
@ -6063,6 +6086,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <array> // array
#include <cstddef> // size_t
#include <cstring> // strlen
@ -6557,6 +6581,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <cstddef>
#include <string> // string
#include <utility> // move
@ -7288,6 +7313,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <array> // array
#include <clocale> // localeconv
#include <cstddef> // size_t
@ -8926,6 +8952,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <cstdint> // size_t
#include <utility> // declval
#include <string> // string
@ -12077,6 +12104,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <cmath> // isfinite
#include <cstdint> // uint8_t
#include <functional> // function
@ -12593,6 +12621,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
// #include <nlohmann/detail/abi_macros.hpp>
// #include <nlohmann/detail/iterators/primitive_iterator.hpp>
@ -12605,6 +12634,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <cstddef> // ptrdiff_t
#include <limits> // numeric_limits
@ -12763,6 +12793,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <iterator> // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next
#include <type_traits> // conditional, is_const, remove_const
@ -13524,6 +13555,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <cstddef> // ptrdiff_t
#include <iterator> // reverse_iterator
#include <utility> // declval
@ -13692,6 +13724,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <algorithm> // all_of
#include <cctype> // isdigit
#include <cerrno> // errno, ERANGE
@ -14686,6 +14719,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <initializer_list>
#include <utility>
@ -14777,6 +14811,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <algorithm> // reverse
#include <array> // array
#include <map> // map
@ -14802,6 +14837,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <algorithm> // copy
#include <cstddef> // size_t
#include <iterator> // back_inserter
@ -16770,6 +16806,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <algorithm> // reverse, remove, fill, find, none_of
#include <array> // array
#include <clocale> // localeconv, lconv
@ -16794,6 +16831,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <array> // array
#include <cmath> // signbit, isfinite
#include <cstdint> // intN_t, uintN_t
@ -18888,6 +18926,7 @@ NLOHMANN_JSON_NAMESPACE_END
// SPDX-License-Identifier: MIT
#include <functional> // equal_to, less
#include <initializer_list> // initializer_list
#include <iterator> // input_iterator_tag, iterator_traits
@ -18909,7 +18948,7 @@ NLOHMANN_JSON_NAMESPACE_BEGIN
template <class Key, class T, class IgnoredLess = std::less<Key>,
class Allocator = std::allocator<std::pair<const Key, T>>>
struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
{
{
using key_type = Key;
using mapped_type = T;
using Container = std::vector<std::pair<const Key, T>, Allocator>;
@ -18925,16 +18964,16 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
// Explicit constructors instead of `using Container::Container`
// otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4)
ordered_map() noexcept(noexcept(Container())) : Container{} {}
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {}
template <class It>
ordered_map(It first, It last, const Allocator& alloc = Allocator())
: Container{first, last, alloc} {}
ordered_map(std::initializer_list<value_type> init, const Allocator& alloc = Allocator() )
: Container{init, alloc} {}
ordered_map() noexcept(noexcept(Container())) : Container{} {}
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {}
template <class It>
ordered_map(It first, It last, const Allocator& alloc = Allocator())
: Container{first, last, alloc} {}
ordered_map(std::initializer_list<value_type> init, const Allocator& alloc = Allocator() )
: Container{init, alloc} {}
std::pair<iterator, bool> emplace(const key_type& key, T&& t)
{
std::pair<iterator, bool> emplace(const key_type& key, T&& t)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -18944,12 +18983,12 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
Container::emplace_back(key, std::forward<T>(t));
return {std::prev(this->end()), true};
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
std::pair<iterator, bool> emplace(KeyType && key, T && t)
{
std::pair<iterator, bool> emplace(KeyType && key, T && t)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -18959,34 +18998,34 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
return {std::prev(this->end()), true};
}
}
T& operator[](const key_type& key)
{
T& operator[](const key_type& key)
{
return emplace(key, T{}).first->second;
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
T & operator[](KeyType && key)
{
T & operator[](KeyType && key)
{
return emplace(std::forward<KeyType>(key), T{}).first->second;
}
}
const T& operator[](const key_type& key) const
{
const T& operator[](const key_type& key) const
{
return at(key);
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
const T & operator[](KeyType && key) const
{
const T & operator[](KeyType && key) const
{
return at(std::forward<KeyType>(key));
}
}
T& at(const key_type& key)
{
T& at(const key_type& key)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -18996,12 +19035,12 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
JSON_THROW(std::out_of_range("key not found"));
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{
T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -19011,10 +19050,10 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
JSON_THROW(std::out_of_range("key not found"));
}
}
const T& at(const key_type& key) const
{
const T& at(const key_type& key) const
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -19024,12 +19063,12 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
JSON_THROW(std::out_of_range("key not found"));
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
{
const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -19039,10 +19078,10 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
JSON_THROW(std::out_of_range("key not found"));
}
}
size_type erase(const key_type& key)
{
size_type erase(const key_type& key)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -19058,12 +19097,12 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return 0;
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{
size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -19079,15 +19118,15 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return 0;
}
}
iterator erase(iterator pos)
{
iterator erase(iterator pos)
{
return erase(pos, std::next(pos));
}
}
iterator erase(iterator first, iterator last)
{
iterator erase(iterator first, iterator last)
{
if (first == last)
{
return first;
@ -19137,10 +19176,10 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
// use this iterator, because it may have been invalidated by the
// resize call. Instead, we can return begin() + offset.
return Container::begin() + offset;
}
}
size_type count(const key_type& key) const
{
size_type count(const key_type& key) const
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -19149,12 +19188,12 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return 0;
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
{
size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -19163,10 +19202,10 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return 0;
}
}
iterator find(const key_type& key)
{
iterator find(const key_type& key)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -19175,12 +19214,12 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return Container::end();
}
}
template<class KeyType, detail::enable_if_t<
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{
iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -19189,10 +19228,10 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return Container::end();
}
}
const_iterator find(const key_type& key) const
{
const_iterator find(const key_type& key) const
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
@ -19201,15 +19240,15 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
return Container::end();
}
}
std::pair<iterator, bool> insert( value_type&& value )
{
std::pair<iterator, bool> insert( value_type&& value )
{
return emplace(value.first, std::move(value.second));
}
}
std::pair<iterator, bool> insert( const value_type& value )
{
std::pair<iterator, bool> insert( const value_type& value )
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, value.first))
@ -19219,24 +19258,24 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
Container::push_back(value);
return {--this->end(), true};
}
}
template<typename InputIt>
using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
template<typename InputIt>
using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
std::input_iterator_tag>::value>::type;
template<typename InputIt, typename = require_input_iter<InputIt>>
void insert(InputIt first, InputIt last)
{
template<typename InputIt, typename = require_input_iter<InputIt>>
void insert(InputIt first, InputIt last)
{
for (auto it = first; it != last; ++it)
{
insert(*it);
}
}
}
private:
JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare();
};
JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare();
};
NLOHMANN_JSON_NAMESPACE_END
@ -23881,7 +23920,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
// the valid JSON Patch operations
enum class patch_operations {add, remove, replace, move, copy, test, invalid};
const auto get_op = [](const std::string & op)
const auto get_op = [](const std::string& op)
{
if (op == "add")
{
@ -24018,8 +24057,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
for (const auto& val : json_patch)
{
// wrapper to get a value for an operation
const auto get_value = [&val](const std::string & op,
const std::string & member,
const auto get_value = [&val](const std::string& op,
const std::string& member,
bool string_type) -> basic_json &
{
// find value
@ -24396,14 +24435,14 @@ struct less< ::nlohmann::detail::value_t> // do not remove the space after '<',
*/
bool operator()(::nlohmann::detail::value_t lhs,
::nlohmann::detail::value_t rhs) const noexcept
{
{
#if JSON_HAS_THREE_WAY_COMPARISON
return std::is_lt(lhs <=> rhs); // *NOPAD*
#else
return ::nlohmann::detail::operator<(lhs, rhs);
#endif
}
};
}
};
// C++20 prohibit function specialization in the std namespace.
#ifndef JSON_HAS_CPP_20
@ -24442,6 +24481,7 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
// SPDX-License-Identifier: MIT
// restore clang diagnostic settings
#if defined(__clang__)
#pragma clang diagnostic pop
@ -24486,6 +24526,7 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
// SPDX-License-Identifier: MIT
#undef JSON_HEDLEY_ALWAYS_INLINE
#undef JSON_HEDLEY_ARM_VERSION
#undef JSON_HEDLEY_ARM_VERSION_CHECK
@ -24636,4 +24677,5 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
#undef JSON_HEDLEY_FALL_THROUGH
#endif // INCLUDE_NLOHMANN_JSON_HPP_

View File

@ -25,6 +25,7 @@
// SPDX-License-Identifier: MIT
// This file contains all macro definitions affecting or depending on the ABI
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK

View File

@ -106,7 +106,7 @@ TEST_CASE("compliance tests from nativejson-benchmark")
SECTION("doubles")
{
auto TEST_DOUBLE = [](const std::string & json_string, const double expected)
auto TEST_DOUBLE = [](const std::string& json_string, const double expected)
{
CAPTURE(json_string)
CAPTURE(expected)
@ -238,7 +238,7 @@ TEST_CASE("compliance tests from nativejson-benchmark")
SECTION("strings")
{
auto TEST_STRING = [](const std::string & json_string, const std::string & expected)
auto TEST_STRING = [](const std::string& json_string, const std::string& expected)
{
CAPTURE(json_string)
CAPTURE(expected)

View File

@ -126,7 +126,7 @@ TEST_CASE("digit gen")
{
SECTION("single precision")
{
auto check_float = [](float number, const std::string & digits, int expected_exponent)
auto check_float = [](float number, const std::string& digits, int expected_exponent)
{
CAPTURE(number)
CAPTURE(digits)
@ -190,7 +190,7 @@ TEST_CASE("digit gen")
SECTION("double precision")
{
auto check_double = [](double number, const std::string & digits, int expected_exponent)
auto check_double = [](double number, const std::string& digits, int expected_exponent)
{
CAPTURE(number)
CAPTURE(digits)
@ -336,7 +336,7 @@ TEST_CASE("formatting")
{
SECTION("single precision")
{
auto check_float = [](float number, const std::string & expected)
auto check_float = [](float number, const std::string& expected)
{
std::array<char, 33> buf{};
char* end = nlohmann::detail::to_chars(buf.data(), buf.data() + 32, number); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
@ -396,7 +396,7 @@ TEST_CASE("formatting")
SECTION("double precision")
{
auto check_double = [](double number, const std::string & expected)
auto check_double = [](double number, const std::string& expected)
{
std::array<char, 33> buf{};
char* end = nlohmann::detail::to_chars(buf.data(), buf.data() + 32, number); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
@ -456,7 +456,7 @@ TEST_CASE("formatting")
SECTION("integer")
{
auto check_integer = [](std::int64_t number, const std::string & expected)
auto check_integer = [](std::int64_t number, const std::string& expected)
{
const nlohmann::json j = number;
CHECK(j.dump() == expected);