aboutsummaryrefslogtreecommitdiff
path: root/src/prevector.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/prevector.h')
-rw-r--r--src/prevector.h31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/prevector.h b/src/prevector.h
index 4776db789b..d14e5f64e9 100644
--- a/src/prevector.h
+++ b/src/prevector.h
@@ -5,13 +5,13 @@
#ifndef BITCOIN_PREVECTOR_H
#define BITCOIN_PREVECTOR_H
-#include <assert.h>
-#include <cstdlib>
-#include <stdint.h>
-#include <string.h>
-
#include <algorithm>
+#include <cassert>
#include <cstddef>
+#include <cstdint>
+#include <cstdlib>
+#include <cstring>
+#include <iterator>
#include <type_traits>
#include <utility>
@@ -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;
@@ -212,7 +210,7 @@ private:
std::fill_n(dst, count, value);
}
- template<typename InputIterator>
+ template <std::input_iterator InputIterator>
void fill(T* dst, InputIterator first, InputIterator last) {
while (first != last) {
new(static_cast<void*>(dst)) T(*first);
@@ -231,7 +229,7 @@ public:
fill(item_ptr(0), n, val);
}
- template<typename InputIterator>
+ template <std::input_iterator InputIterator>
void assign(InputIterator first, InputIterator last) {
size_type n = last - first;
clear();
@@ -242,7 +240,7 @@ public:
fill(item_ptr(0), first, last);
}
- prevector() {}
+ prevector() = default;
explicit prevector(size_type n) {
resize(n);
@@ -254,7 +252,7 @@ public:
fill(item_ptr(0), n, val);
}
- template<typename InputIterator>
+ template <std::input_iterator InputIterator>
prevector(InputIterator first, InputIterator last) {
size_type n = last - first;
change_capacity(n);
@@ -365,7 +363,8 @@ public:
change_capacity(new_size + (new_size >> 1));
}
T* ptr = item_ptr(p);
- memmove(ptr + 1, ptr, (size() - p) * sizeof(T));
+ T* dst = ptr + 1;
+ memmove(dst, ptr, (size() - p) * sizeof(T));
_size++;
new(static_cast<void*>(ptr)) T(value);
return iterator(ptr);
@@ -378,12 +377,13 @@ public:
change_capacity(new_size + (new_size >> 1));
}
T* ptr = item_ptr(p);
- memmove(ptr + count, ptr, (size() - p) * sizeof(T));
+ T* dst = ptr + count;
+ memmove(dst, ptr, (size() - p) * sizeof(T));
_size += count;
fill(item_ptr(p), count, value);
}
- template<typename InputIterator>
+ template <std::input_iterator InputIterator>
void insert(iterator pos, InputIterator first, InputIterator last) {
size_type p = pos - begin();
difference_type count = last - first;
@@ -392,7 +392,8 @@ public:
change_capacity(new_size + (new_size >> 1));
}
T* ptr = item_ptr(p);
- memmove(ptr + count, ptr, (size() - p) * sizeof(T));
+ T* dst = ptr + count;
+ memmove(dst, ptr, (size() - p) * sizeof(T));
_size += count;
fill(ptr, first, last);
}