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
..
2026-01-01 20:00:39 +01:00
2026-09-25 08:29:02 +02:00
2026-09-27 16:56:21 +02:00
2026-09-24 17:02:57 +02:00
2026-09-24 17:02:57 +02:00
2026-09-24 17:02:57 +02:00
2026-09-24 17:02:57 +02:00
2026-09-25 08:29:02 +02:00
2026-01-01 20:00:39 +01:00
2026-09-25 08:29:02 +02:00
2026-09-16 20:15:46 +02:00
2026-09-27 14:28:38 +02:00
2026-07-31 18:04:30 +02:00
2026-07-08 16:40:58 +02:00
2026-09-27 14:19:22 +02:00
2026-09-30 20:07:29 +02:00
2026-01-01 20:00:39 +01:00
2026-09-27 16:56:21 +02:00
2026-09-27 16:56:21 +02:00
2026-09-27 14:28:38 +02:00
2026-09-27 16:56:21 +02:00
2026-09-24 17:05:37 +02:00
2026-09-30 20:07:41 +02:00
2026-09-16 20:15:46 +02:00
2026-01-01 20:00:39 +01:00
2026-09-28 17:51:07 +02:00
2026-09-27 14:19:22 +02:00
2026-01-01 20:00:39 +01:00
2026-09-30 20:06:26 +02:00
2026-09-30 20:07:37 +02:00
2026-09-27 14:21:58 +02:00
2026-01-01 20:00:39 +01:00
2026-07-09 20:38:39 +02:00
2026-01-01 20:00:39 +01:00
2026-09-11 08:22:50 +02:00
2026-09-30 20:07:29 +02:00
2026-09-30 20:07:16 +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:33 +02:00
2026-09-27 14:19:22 +02:00
2026-09-30 20:07:41 +02:00
2026-09-30 20:06:34 +02:00
2026-09-30 20:07:06 +02:00
2026-09-30 20:07:45 +02:00
2026-09-27 16:56:21 +02:00
2026-07-02 15:59:36 +02:00
2026-09-24 17:12:02 +02:00
2026-01-01 20:00:39 +01:00
2026-09-09 09:52:58 +02:00
2026-09-09 09:52:58 +02:00
2026-01-01 20:00:39 +01:00
2026-07-09 20:38:39 +02:00
2026-01-01 20:00:39 +01:00
2026-09-30 20:07:10 +02:00
2026-09-30 20:06:59 +02:00
2026-09-27 14:28:38 +02:00
2026-09-28 22:20:43 +02:00
2026-09-27 14:19:22 +02:00
2026-01-01 20:00:39 +01:00
2026-09-30 20:07:16 +02:00
2026-09-30 20:07:19 +02:00
2026-09-16 20:15:46 +02:00
2026-09-09 09:48:17 +02:00
2026-09-16 20:15:46 +02:00
2026-01-01 20:00:39 +01:00
2026-09-27 16:56:21 +02:00
2026-09-24 17:01:15 +02:00
2026-09-30 20:06:34 +02:00
2026-01-01 20:00:39 +01:00
2026-09-30 20:07:33 +02:00
2026-01-01 20:00:39 +01:00
2026-01-01 20:00:39 +01:00
2026-09-28 17:51:07 +02:00
2026-09-27 16:56:21 +02:00
2026-09-27 16:56:21 +02:00
2026-09-27 14:19:22 +02:00
2026-09-27 14:19:22 +02:00
2026-01-01 20:00:39 +01:00
2026-01-01 20:00:39 +01:00
2026-08-03 08:35:53 +02:00
2026-09-27 14:28:38 +02:00
2026-01-01 20:00:39 +01:00
2026-09-25 20:44:30 +02:00
2026-01-01 20:00:39 +01:00
2026-09-09 09:50:39 +02:00
2026-09-09 09:50:39 +02:00
2026-09-16 20:16:43 +02:00
2026-09-16 20:16:43 +02:00
2026-09-16 20:16:43 +02:00
2026-09-10 17:20:48 +02:00
2026-01-01 20:00:39 +01:00
2026-09-27 14:19:22 +02:00
2026-01-01 20:00:39 +01:00