Skip to content

Commit 85a713c

Browse files
nlohmannslowriot
authored andcommitted
Enable modernize-use-integer-sign-comparison check (nlohmann#4581)
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
1 parent 2422cd2 commit 85a713c

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ Checks: '*,
5353
-modernize-type-traits,
5454
-modernize-use-constraints,
5555
-modernize-use-designated-initializers,
56-
-modernize-use-integer-sign-comparison,
5756
-modernize-use-nodiscard,
5857
-modernize-use-ranges,
5958
-modernize-use-std-numbers,

tests/src/unit-alt-string.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class alt_string
2828
public:
2929
using value_type = std::string::value_type;
3030

31-
static constexpr auto npos = static_cast<std::size_t>(-1);
31+
static constexpr auto npos = (std::numeric_limits<std::size_t>::max)();
3232

3333
alt_string(const char* str): str_impl(str) {}
3434
alt_string(const char* str, std::size_t count): str_impl(str, count) {}

tests/src/unit-class_parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class SaxEventLogger
7575

7676
bool start_object(std::size_t elements)
7777
{
78-
if (elements == static_cast<std::size_t>(-1))
78+
if (elements == (std::numeric_limits<std::size_t>::max)())
7979
{
8080
events.emplace_back("start_object()");
8181
}
@@ -100,7 +100,7 @@ class SaxEventLogger
100100

101101
bool start_array(std::size_t elements)
102102
{
103-
if (elements == static_cast<std::size_t>(-1))
103+
if (elements == (std::numeric_limits<std::size_t>::max)())
104104
{
105105
events.emplace_back("start_array()");
106106
}

tests/src/unit-class_parser_diagnostic_positions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class SaxEventLogger
8080

8181
bool start_object(std::size_t elements)
8282
{
83-
if (elements == static_cast<std::size_t>(-1))
83+
if (elements == (std::numeric_limits<std::size_t>::max)())
8484
{
8585
events.emplace_back("start_object()");
8686
}
@@ -105,7 +105,7 @@ class SaxEventLogger
105105

106106
bool start_array(std::size_t elements)
107107
{
108-
if (elements == static_cast<std::size_t>(-1))
108+
if (elements == (std::numeric_limits<std::size_t>::max)())
109109
{
110110
events.emplace_back("start_array()");
111111
}

tests/src/unit-deserialization.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct SaxEventLogger : public nlohmann::json_sax<json>
7676

7777
bool start_object(std::size_t elements) override
7878
{
79-
if (elements == static_cast<std::size_t>(-1))
79+
if (elements == (std::numeric_limits<std::size_t>::max)())
8080
{
8181
events.emplace_back("start_object()");
8282
}
@@ -101,7 +101,7 @@ struct SaxEventLogger : public nlohmann::json_sax<json>
101101

102102
bool start_array(std::size_t elements) override
103103
{
104-
if (elements == static_cast<std::size_t>(-1))
104+
if (elements == (std::numeric_limits<std::size_t>::max)())
105105
{
106106
events.emplace_back("start_array()");
107107
}
@@ -131,7 +131,7 @@ struct SaxEventLoggerExitAfterStartObject : public SaxEventLogger
131131
{
132132
bool start_object(std::size_t elements) override
133133
{
134-
if (elements == static_cast<std::size_t>(-1))
134+
if (elements == (std::numeric_limits<std::size_t>::max)())
135135
{
136136
events.emplace_back("start_object()");
137137
}
@@ -156,7 +156,7 @@ struct SaxEventLoggerExitAfterStartArray : public SaxEventLogger
156156
{
157157
bool start_array(std::size_t elements) override
158158
{
159-
if (elements == static_cast<std::size_t>(-1))
159+
if (elements == (std::numeric_limits<std::size_t>::max)())
160160
{
161161
events.emplace_back("start_array()");
162162
}

0 commit comments

Comments
 (0)