Skip to content

Commit e736b67

Browse files
committed
Merge #14715: Drop defunct prevector compat handling
69ca487 Implement prevector::fill once (Ben Woosley) 7bad78c Drop defunct IS_TRIVIALLY_CONSTRUCTIBLE handling from prevector.h (Ben Woosley) Pull request description: This is clean-up post #14651: * Use one implementation of `prevector::fill`, as it's possible now that the implementations are identical. * Only apply the `IS_TRIVIALLY_CONSTRUCTIBLE` handling to the bench file where it is used, and drop the now-unnecessary associated compat includes. Tree-SHA512: 5930b3a17fccd39af10add40202ad97a297aebecc049af72ca920d0d55b3e4c3c30ce864c8a683355895f0196396d4ea56ba9f9637bdc7d16964cdf66c195485
2 parents d7b0258 + 69ca487 commit e736b67

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

src/bench/prevector.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,21 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#include <compat.h>
65
#include <prevector.h>
76
#include <serialize.h>
87
#include <streams.h>
8+
#include <type_traits>
99

1010
#include <bench/bench.h>
1111

12+
// GCC 4.8 is missing some C++11 type_traits,
13+
// https://www.gnu.org/software/gcc/gcc-5/changes.html
14+
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
15+
#define IS_TRIVIALLY_CONSTRUCTIBLE std::has_trivial_default_constructor
16+
#else
17+
#define IS_TRIVIALLY_CONSTRUCTIBLE std::is_trivially_default_constructible
18+
#endif
19+
1220
struct nontrivial_t {
1321
int x;
1422
nontrivial_t() :x(-1) {}

src/compat.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@
1010
#include <config/bitcoin-config.h>
1111
#endif
1212

13-
#include <type_traits>
14-
15-
// GCC 4.8 is missing some C++11 type_traits,
16-
// https://www.gnu.org/software/gcc/gcc-5/changes.html
17-
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
18-
#define IS_TRIVIALLY_CONSTRUCTIBLE std::has_trivial_default_constructor
19-
#else
20-
#define IS_TRIVIALLY_CONSTRUCTIBLE std::is_trivially_default_constructible
21-
#endif
22-
2313
#ifdef WIN32
2414
#ifdef _WIN32_WINNT
2515
#undef _WIN32_WINNT

src/prevector.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include <iterator>
1616
#include <type_traits>
1717

18-
#include <compat.h>
19-
2018
#pragma pack(push, 1)
2119
/** Implements a drop-in replacement for std::vector<T> which stores up to N
2220
* elements directly (without heap allocation). The types Size and Diff are
@@ -198,11 +196,7 @@ class prevector {
198196
T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); }
199197
const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); }
200198

201-
void fill(T* dst, ptrdiff_t count) {
202-
std::fill_n(dst, count, T{});
203-
}
204-
205-
void fill(T* dst, ptrdiff_t count, const T& value) {
199+
void fill(T* dst, ptrdiff_t count, const T& value = T{}) {
206200
std::fill_n(dst, count, value);
207201
}
208202

0 commit comments

Comments
 (0)