Niels Lohmann
6ae17630a4
Reject integral keys for contains(), find(), and count() at compile time ( #5705 )
...
j.contains(0), j.find(0), and j.count(0) used to compile: the literal 0 is
a null pointer constant, so it converts to a null const char*, and the
overloads taking const typename object_t::key_type& accepted it by
constructing a std::string from that null pointer, which is undefined
behavior (a crash with both libc++ and libstdc++). value(0, default_value)
had the same problem in C++11, where the object comparator is not
transparent.
Add deleted overloads for integral arguments to contains(), find()
(const and non-const), count(), and value() so that these calls are
compile errors in every supported language mode instead of crashing.
Calls with string, string_view, json_pointer, and size-typed element
access (at(), operator[](), erase()) are unaffected.
Fixes #5657 .
Signed-off-by: Niels Lohmann <mail@nlohmann.me >
2026-09-30 20:07:45 +02:00
..
2022-08-05 19:51:39 +02:00
2026-09-24 06:55:21 +02:00
2026-09-15 20:46:37 +02:00
2026-07-04 11:13:25 +02:00
2026-06-29 22:15:18 +02:00
2025-04-05 18:54:35 +02:00
2026-07-10 16:01:08 +02:00
2022-05-01 09:41:50 +02:00
2026-09-15 20:46:37 +02:00
2025-04-05 18:54:35 +02:00
2026-09-15 20:46:37 +02:00
2022-05-01 09:41:50 +02:00
2026-09-27 20:40:13 +02:00
2022-05-01 09:41:50 +02:00
2026-09-30 20:06:51 +02:00
2026-09-30 20:07:45 +02:00
2026-09-30 20:07:45 +02:00
2026-06-29 22:15:18 +02:00
2026-06-29 22:15:18 +02:00
2022-05-17 13:08:56 +02:00
2026-06-29 22:15:18 +02:00
2026-07-26 08:29:31 +00:00
2026-07-04 11:13:25 +02:00
2026-07-04 11:13:25 +02:00
2025-05-04 10:28:24 +02:00
2025-01-17 06:53:35 +01:00
2022-05-01 09:41:50 +02:00
2026-07-04 11:13:25 +02:00
2026-06-30 18:09:06 +02:00
2024-12-09 23:02:30 +01:00
2026-09-30 20:07:45 +02:00
2025-04-05 18:54:35 +02:00
2026-07-09 17:24:19 +02:00
2026-09-27 16:56:21 +02:00
2026-09-27 16:56:21 +02:00
2026-09-27 16:56:21 +02:00
2026-09-28 17:51:07 +02:00
2026-09-28 17:51:07 +02:00
2026-09-27 16:56:21 +02:00
2025-04-05 18:54:35 +02:00
2022-05-17 13:08:56 +02:00
2026-06-29 22:15:18 +02:00
2024-12-09 23:02:30 +01:00
2024-12-06 18:38:25 +01:00
2026-09-25 18:02:38 +02:00
2026-07-09 17:24:19 +02:00
2026-09-27 16:56:21 +02:00
2026-09-27 16:56:21 +02:00
2026-09-30 20:07:16 +02:00
2026-06-29 22:15:18 +02:00
2022-05-01 09:41:50 +02:00
2025-04-05 18:54:35 +02:00
2022-05-01 09:41:50 +02:00
2026-06-29 22:15:18 +02:00
2022-05-01 09:41:50 +02:00
2025-04-05 18:54:35 +02:00
2025-04-05 18:54:35 +02:00
2025-04-05 18:54:35 +02:00
2026-06-29 22:15:18 +02:00
2022-05-01 09:41:50 +02:00
2025-04-05 18:54:35 +02:00
2022-05-01 09:41:50 +02:00
2025-04-05 18:54:35 +02:00
2026-07-10 16:01:08 +02:00
2026-09-15 20:46:37 +02:00
2026-09-15 20:46:37 +02:00
2022-07-29 14:28:37 +02:00
2022-05-01 09:41:50 +02:00
2026-06-29 22:15:18 +02:00
2026-09-15 20:46:37 +02:00
2026-09-15 20:46:37 +02:00
2026-09-15 20:46:37 +02:00
2026-09-15 20:46:37 +02:00
2026-09-15 20:46:37 +02:00
2026-07-04 11:13:25 +02:00
2026-06-29 22:15:18 +02:00
2026-06-29 22:15:18 +02:00
2024-07-07 10:22:17 +02:00
2025-04-05 18:54:35 +02:00
2024-07-07 10:22:17 +02:00
2026-07-09 20:57:41 +02:00
2022-08-05 19:51:39 +02:00
2022-05-01 09:41:50 +02:00
2026-07-04 11:13:25 +02:00
2026-09-30 20:07:06 +02:00
2026-06-29 22:15:18 +02:00
2026-06-29 22:15:18 +02:00
2026-06-29 22:15:18 +02:00
2026-06-29 22:15:18 +02:00
2026-09-27 16:56:21 +02:00
2026-06-29 22:15:18 +02:00
2026-09-30 20:07:33 +02:00
2026-08-04 08:45:02 +02:00
2026-09-09 09:49:12 +02:00
2026-09-09 09:49:12 +02:00
2026-07-04 11:13:25 +02:00
2026-06-29 22:15:18 +02:00
2026-06-29 22:15:18 +02:00
2026-09-27 16:56:21 +02:00
2022-05-01 09:41:50 +02:00
2025-01-17 06:53:35 +01:00
2026-07-09 17:24:19 +02:00
2022-07-29 14:28:37 +02:00
2026-06-29 22:15:18 +02:00
2026-09-15 20:46:37 +02:00
2026-09-30 20:07:24 +02:00
2026-09-27 16:56:21 +02:00
2026-09-27 16:56:21 +02:00
2026-09-30 20:07:41 +02:00
2026-09-27 16:56:21 +02:00
2026-09-30 20:07:19 +02:00
2026-07-04 11:13:25 +02:00
2026-09-27 16:56:21 +02:00
2026-06-29 22:15:18 +02:00
2026-07-09 17:24:19 +02:00
2022-05-01 09:41:50 +02:00
2026-09-15 20:46:37 +02:00
2026-07-04 11:13:25 +02:00
2022-08-05 19:51:39 +02:00
2026-09-30 20:07:45 +02:00