Update nlohmann::json to 3.9.1

Release notes:
https://github.com/nlohmann/json/releases/tag/v3.9.1
This commit is contained in:
Jon Evans 2021-03-02 14:55:51 -05:00
parent 9004fbcdc4
commit 24e375742b
1 changed files with 109 additions and 10 deletions

View File

@ -1,7 +1,7 @@
/*
__ _____ _____ _____
__| | __| | | | JSON for Modern C++
| | |__ | | | | | | version 3.9.0
| | |__ | | | | | | version 3.9.1
|_____|_____|_____|_|___| https://github.com/nlohmann/json
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
@ -32,7 +32,7 @@ SOFTWARE.
#define NLOHMANN_JSON_VERSION_MAJOR 3
#define NLOHMANN_JSON_VERSION_MINOR 9
#define NLOHMANN_JSON_VERSION_PATCH 0
#define NLOHMANN_JSON_VERSION_PATCH 1
#include <algorithm> // all_of, find, for_each
#include <cstddef> // nullptr_t, ptrdiff_t, size_t
@ -6759,14 +6759,13 @@ class lexer : public lexer_base<BasicJsonType>
default:
{
unget();
break;
continue;
}
}
}
break; // quiet CLang compiler
default:
break;
continue;
}
}
}
@ -7391,7 +7390,7 @@ scan_number_done:
skip_whitespace();
// ignore comments
if (ignore_comments && current == '/')
while (ignore_comments && current == '/')
{
if (!scan_comment())
{
@ -16409,6 +16408,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
using mapped_type = T;
using Container = std::vector<std::pair<const Key, T>, Allocator>;
using typename Container::iterator;
using typename Container::const_iterator;
using typename Container::size_type;
using typename Container::value_type;
@ -16421,7 +16421,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
ordered_map(std::initializer_list<T> init, const Allocator& alloc = Allocator() )
: Container{init, alloc} {}
std::pair<iterator, bool> emplace(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)
{
@ -16434,9 +16434,40 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
return {--this->end(), true};
}
T& operator[](Key&& key)
T& operator[](const Key& key)
{
return emplace(std::move(key), T{}).first->second;
return emplace(key, T{}).first->second;
}
const T& operator[](const Key& key) const
{
return at(key);
}
T& at(const Key& key)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (it->first == key)
{
return it->second;
}
}
throw std::out_of_range("key not found");
}
const T& at(const Key& key) const
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (it->first == key)
{
return it->second;
}
}
throw std::out_of_range("key not found");
}
size_type erase(const Key& key)
@ -16457,6 +16488,74 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
return 0;
}
iterator erase(iterator pos)
{
auto it = pos;
// Since we cannot move const Keys, re-construct them in place
for (auto next = it; ++next != this->end(); ++it)
{
it->~value_type(); // Destroy but keep allocation
new (&*it) value_type{std::move(*next)};
}
Container::pop_back();
return pos;
}
size_type count(const Key& key) const
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (it->first == key)
{
return 1;
}
}
return 0;
}
iterator find(const Key& key)
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (it->first == key)
{
return it;
}
}
return Container::end();
}
const_iterator find(const Key& key) const
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (it->first == key)
{
return it;
}
}
return Container::end();
}
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 )
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (it->first == value.first)
{
return {it, false};
}
}
Container::push_back(value);
return {--this->end(), true};
}
};
} // namespace nlohmann
@ -17441,7 +17540,7 @@ class basic_json
object = nullptr; // silence warning, see #821
if (JSON_HEDLEY_UNLIKELY(t == value_t::null))
{
JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.9.0")); // LCOV_EXCL_LINE
JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.9.1")); // LCOV_EXCL_LINE
}
break;
}