From d4444419001ca2af4c601a996461b67110645a52 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 2 Feb 2024 11:35:23 +0100 Subject: [PATCH 1/2] refactor: Allow CScript construction from any std::input_iterator Also, remove the value_type alias, which is not needed when element_type is present. --- src/prevector.h | 2 -- src/script/script.h | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/prevector.h b/src/prevector.h index 6dcc305268f..f7970daa454 100644 --- a/src/prevector.h +++ b/src/prevector.h @@ -50,7 +50,6 @@ public: T* ptr{}; public: typedef Diff difference_type; - typedef T value_type; typedef T* pointer; typedef T& reference; using element_type = T; @@ -102,7 +101,6 @@ public: const T* ptr{}; public: typedef Diff difference_type; - typedef const T value_type; typedef const T* pointer; typedef const T& reference; using element_type = const T; diff --git a/src/script/script.h b/src/script/script.h index 035152ee510..a11e73517a1 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -429,11 +429,11 @@ protected: } return *this; } + public: CScript() = default; - CScript(const_iterator pbegin, const_iterator pend) : CScriptBase(pbegin, pend) { } - CScript(std::vector::const_iterator pbegin, std::vector::const_iterator pend) : CScriptBase(pbegin, pend) { } - CScript(const unsigned char* pbegin, const unsigned char* pend) : CScriptBase(pbegin, pend) { } + template + CScript(InputIterator first, InputIterator last) : CScriptBase{first, last} { } SERIALIZE_METHODS(CScript, obj) { READWRITE(AsBase(obj)); } From fa7b9b99a2ed466d1765d748f4a59c2f581b974f Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 21 Feb 2024 12:42:59 +0100 Subject: [PATCH 2/2] refactor: Require std::input_iterator for all InputIterator in prevector --- src/prevector.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/prevector.h b/src/prevector.h index f7970daa454..0c47137910b 100644 --- a/src/prevector.h +++ b/src/prevector.h @@ -5,13 +5,13 @@ #ifndef BITCOIN_PREVECTOR_H #define BITCOIN_PREVECTOR_H -#include -#include -#include -#include - #include +#include #include +#include +#include +#include +#include #include #include @@ -210,7 +210,7 @@ private: std::fill_n(dst, count, value); } - template + template void fill(T* dst, InputIterator first, InputIterator last) { while (first != last) { new(static_cast(dst)) T(*first); @@ -229,7 +229,7 @@ public: fill(item_ptr(0), n, val); } - template + template void assign(InputIterator first, InputIterator last) { size_type n = last - first; clear(); @@ -252,7 +252,7 @@ public: fill(item_ptr(0), n, val); } - template + template prevector(InputIterator first, InputIterator last) { size_type n = last - first; change_capacity(n); @@ -381,7 +381,7 @@ public: fill(item_ptr(p), count, value); } - template + template void insert(iterator pos, InputIterator first, InputIterator last) { size_type p = pos - begin(); difference_type count = last - first;