Skip to content

Commit 44de325

Browse files
committed
refactor: Split util::insert into its own file
1 parent 9ec5da3 commit 44de325

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ BITCOIN_CORE_H = \
297297
util/golombrice.h \
298298
util/hash_type.h \
299299
util/hasher.h \
300+
util/insert.h \
300301
util/macros.h \
301302
util/message.h \
302303
util/moneystr.h \

src/util/insert.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2023 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef BITCOIN_UTIL_INSERT_H
6+
#define BITCOIN_UTIL_INSERT_H
7+
8+
#include <set>
9+
10+
namespace util {
11+
12+
//! Simplification of std insertion
13+
template <typename Tdst, typename Tsrc>
14+
inline void insert(Tdst& dst, const Tsrc& src) {
15+
dst.insert(dst.begin(), src.begin(), src.end());
16+
}
17+
template <typename TsetT, typename Tsrc>
18+
inline void insert(std::set<TsetT>& dst, const Tsrc& src) {
19+
dst.insert(src.begin(), src.end());
20+
}
21+
22+
} // namespace util
23+
24+
#endif // BITCOIN_UTIL_INSERT_H

src/util/system.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ int GetNumCores();
3838

3939
namespace util {
4040

41-
//! Simplification of std insertion
42-
template <typename Tdst, typename Tsrc>
43-
inline void insert(Tdst& dst, const Tsrc& src) {
44-
dst.insert(dst.begin(), src.begin(), src.end());
45-
}
46-
template <typename TsetT, typename Tsrc>
47-
inline void insert(std::set<TsetT>& dst, const Tsrc& src) {
48-
dst.insert(src.begin(), src.end());
49-
}
50-
5141
/**
5242
* Helper function to access the contained object of a std::any instance.
5343
* Returns a pointer to the object if passed instance has a value and the type

src/wallet/coinselection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include <policy/feerate.h>
1212
#include <primitives/transaction.h>
1313
#include <random.h>
14-
#include <util/system.h>
1514
#include <util/check.h>
15+
#include <util/insert.h>
1616
#include <util/result.h>
1717

1818
#include <optional>

0 commit comments

Comments
 (0)