Skip to content

Commit 218f801

Browse files
committed
Allocator macro style and comments, remove unused vargs.
1 parent 273de39 commit 218f801

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

include/bitcoin/system/allocator.hpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,26 @@ inline bool operator==(const allocator<Left>& left,
279279

280280
using byte_allocator = allocator<uint8_t>;
281281

282-
#define CREATE(Type, allocate, ...) \
283-
allocate.new_object<Type>(__VA_ARGS__), allocate.deleter<Type>(), allocate
282+
// If Type accepts an allocator on construct (e.g. vector) then
283+
// std::uses_allocator_construction_args supplies the allocator.
284+
285+
// Create a pointer to an instance of Type presumed to be allocated and
286+
// constructed by allocator, and pass it and deleter and allocator as:
287+
// shared_ptr<Type>(Type*, allocate.deleter<Type>(), allocate)
284288
#define POINTER(Type, allocate, ptr) \
285289
ptr, allocate.deleter<Type>(), allocate
286-
#define INPLACE(ptr, Type, allocate, ...) \
287-
allocate.construct<std::shared_ptr<const Type>>(ptr, __VA_ARGS__, \
288-
allocate.deleter<Type>(), allocate)
290+
291+
// Create a pointer to an instance of Type allocated and constructed by
292+
// allocator, and pass it and deleter and allocator as:
293+
// shared_ptr<Type>(allocate.new_object<Type>(...), allocate.deleter<Type>(), allocate)
294+
#define CREATE(Type, allocate, ...) \
295+
POINTER(Type, allocate, allocate.new_object<Type>(__VA_ARGS__))
296+
297+
// Construct a shared_ptr to allocated instance (ptr) of const Type on an
298+
// allocated address (at) passing deleter and allocator to shared_ptr construct.
299+
#define INPLACE(at, Type, allocate, ptr) \
300+
allocate.construct<std::shared_ptr<const Type>>( \
301+
at, ptr, allocate.deleter<Type>(), allocate)
289302

290303
// TODO: replace above macros with parameter pack expansion.
291304
////template <typename Type, typename Allocator, typename... Args>

0 commit comments

Comments
 (0)