Skip to content

Commit 433da31

Browse files
committed
⚗️ try to use GCC 10
1 parent 7b98df5 commit 433da31

8 files changed

Lines changed: 73 additions & 21 deletions

File tree

.github/workflows/ubuntu.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@ jobs:
88

99
steps:
1010
- uses: actions/checkout@v1
11+
- name: install_gcc
12+
run: |
13+
sudo apt update
14+
sudo apt install gcc-10 g++-10
15+
shell: bash
1116
- name: cmake
1217
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
18+
env:
19+
CC: gcc-10
20+
CXX: g++-10
1321
- name: build
1422
run: cmake --build build --parallel 10
1523
- name: test

.travis.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,6 @@ matrix:
300300
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
301301
packages: ['g++-7', 'clang-7', 'ninja-build']
302302

303-
- os: linux
304-
compiler: clang
305-
env:
306-
- COMPILER=clang++-7
307-
- CXX_STANDARD=20
308-
addons:
309-
apt:
310-
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
311-
packages: ['g++-7', 'clang-7', 'ninja-build']
312-
313303
################
314304
# build script #
315305
################

include/nlohmann/detail/iterators/iter_impl.hpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,30 @@ class iter_impl
393393
@brief comparison: equal
394394
@pre The iterator is initialized; i.e. `m_object != nullptr`.
395395
*/
396-
bool operator==(const iter_impl& other) const
396+
bool operator==(const iter_impl<const BasicJsonType>& other) const
397+
{
398+
// if objects are not the same, the comparison is undefined
399+
if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
400+
{
401+
JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers"));
402+
}
403+
404+
JSON_ASSERT(m_object != nullptr);
405+
406+
switch (m_object->m_type)
407+
{
408+
case value_t::object:
409+
return (m_it.object_iterator == other.m_it.object_iterator);
410+
411+
case value_t::array:
412+
return (m_it.array_iterator == other.m_it.array_iterator);
413+
414+
default:
415+
return (m_it.primitive_iterator == other.m_it.primitive_iterator);
416+
}
417+
}
418+
419+
bool operator==(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) const
397420
{
398421
// if objects are not the same, the comparison is undefined
399422
if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))

single_include/nlohmann/json.hpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11279,7 +11279,30 @@ class iter_impl
1127911279
@brief comparison: equal
1128011280
@pre The iterator is initialized; i.e. `m_object != nullptr`.
1128111281
*/
11282-
bool operator==(const iter_impl& other) const
11282+
bool operator==(const iter_impl<const BasicJsonType>& other) const
11283+
{
11284+
// if objects are not the same, the comparison is undefined
11285+
if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
11286+
{
11287+
JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers"));
11288+
}
11289+
11290+
JSON_ASSERT(m_object != nullptr);
11291+
11292+
switch (m_object->m_type)
11293+
{
11294+
case value_t::object:
11295+
return (m_it.object_iterator == other.m_it.object_iterator);
11296+
11297+
case value_t::array:
11298+
return (m_it.array_iterator == other.m_it.array_iterator);
11299+
11300+
default:
11301+
return (m_it.primitive_iterator == other.m_it.primitive_iterator);
11302+
}
11303+
}
11304+
11305+
bool operator==(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) const
1128311306
{
1128411307
// if objects are not the same, the comparison is undefined
1128511308
if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))

test/src/unit-class_parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ TEST_CASE("parser class")
509509
CHECK(parser_helper("\"\"").get<json::string_t>() == "");
510510
CHECK(parser_helper("\"🎈\"").get<json::string_t>() == "🎈");
511511

512-
CHECK(parser_helper("\"\\ud80c\\udc60\"").get<json::string_t>() == u8"\U00013060");
512+
CHECK(parser_helper("\"\\ud80c\\udc60\"").get<json::string_t>() == "\U00013060");
513513
CHECK(parser_helper("\"\\ud83c\\udf1e\"").get<json::string_t>() == "🌞");
514514
}
515515
}

test/src/unit-items.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,3 +1448,11 @@ TEST_CASE("items()")
14481448
}
14491449
}
14501450
}
1451+
1452+
#ifdef JSON_HAS_CPP_17
1453+
#undef JSON_HAS_CPP_17
1454+
#endif
1455+
1456+
#ifdef JSON_HAS_CPP_14
1457+
#undef JSON_HAS_CPP_14
1458+
#endif

test/src/unit-regression1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ TEST_CASE("regression tests 1")
400400

401401
SECTION("issue #146 - character following a surrogate pair is skipped")
402402
{
403-
CHECK(json::parse("\"\\ud80c\\udc60abc\"").get<json::string_t>() == u8"\U00013060abc");
403+
CHECK(json::parse("\"\\ud80c\\udc60abc\"").get<json::string_t>() == "\U00013060abc");
404404
}
405405

406406
SECTION("issue #171 - Cannot index by key of type static constexpr const char*")

test/src/unit-udt.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ static void to_json(BasicJsonType& j, country c)
112112
switch (c)
113113
{
114114
case country::china:
115-
j = u8"中华人民共和国";
115+
j = "中华人民共和国";
116116
return;
117117
case country::france:
118118
j = "France";
119119
return;
120120
case country::russia:
121-
j = u8"Российская Федерация";
121+
j = "Российская Федерация";
122122
return;
123123
default:
124124
break;
@@ -201,9 +201,9 @@ static void from_json(const BasicJsonType& j, country& c)
201201
const auto str = j.template get<std::string>();
202202
static const std::map<std::string, country> m =
203203
{
204-
{u8"中华人民共和国", country::china},
204+
{"中华人民共和国", country::china},
205205
{"France", country::france},
206-
{u8"Российская Федерация", country::russia}
206+
{"Российская Федерация", country::russia}
207207
};
208208

209209
const auto it = m.find(str);
@@ -248,7 +248,7 @@ TEST_CASE("basic usage" * doctest::test_suite("udt"))
248248
const udt::name n{"theo"};
249249
const udt::country c{udt::country::france};
250250
const udt::person sfinae_addict{a, n, c};
251-
const udt::person senior_programmer{{42}, {u8"王芳"}, udt::country::china};
251+
const udt::person senior_programmer{{42}, {"王芳"}, udt::country::china};
252252
const udt::address addr{"Paris"};
253253
const udt::contact cpp_programmer{sfinae_addict, addr};
254254
const udt::contact_book book{{"C++"}, {cpp_programmer, {senior_programmer, addr}}};
@@ -265,14 +265,14 @@ TEST_CASE("basic usage" * doctest::test_suite("udt"))
265265

266266
CHECK(
267267
json(book) ==
268-
u8R"({"name":"C++", "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"_json);
268+
R"({"name":"C++", "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"_json);
269269

270270
}
271271

272272
SECTION("conversion from json via free-functions")
273273
{
274274
const auto big_json =
275-
u8R"({"name":"C++", "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"_json;
275+
R"({"name":"C++", "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"_json;
276276
SECTION("via explicit calls to get")
277277
{
278278
const auto parsed_book = big_json.get<udt::contact_book>();

0 commit comments

Comments
 (0)