From 085fdea88cb48768ae6faec6d5fbf073344fb5f0 Mon Sep 17 00:00:00 2001 From: Lee *!* Clagett Date: Mon, 6 Nov 2023 16:26:39 -0500 Subject: Add compile-time check for input iterators in ::wire array writing --- contrib/epee/include/serialization/wire/write.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/contrib/epee/include/serialization/wire/write.h b/contrib/epee/include/serialization/wire/write.h index c18f7dbcc..c2359918c 100644 --- a/contrib/epee/include/serialization/wire/write.h +++ b/contrib/epee/include/serialization/wire/write.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -188,7 +189,13 @@ namespace wire_write template inline std::size_t array_size(std::true_type, const T& source) - { return boost::size(source); } + { + static_assert( + !std::is_same::iterator_category, std::input_iterator_tag>{}, + "Input iterators must use json (or similar) derived classes directly" + ); + return boost::size(source); + } template inline constexpr std::size_t array_size(std::false_type, const T&) noexcept -- cgit v1.2.3