Add test_reference.cpp
This commit is contained in:
@@ -385,9 +385,14 @@ template <typename T, typename... Args> Ref<T> make_ref(Args &&...args) {
|
||||
constexpr size_t padded_cb_size =
|
||||
(cb_size + alignment - 1) & ~(alignment - 1);
|
||||
|
||||
constexpr size_t total_alignment =
|
||||
std::max(alignof(detail::ControlBlock), alignment);
|
||||
constexpr size_t total_size = padded_cb_size + sizeof(T);
|
||||
constexpr size_t aligned_total_size =
|
||||
(total_size + total_alignment - 1) & ~(total_alignment - 1);
|
||||
|
||||
char *buf = reinterpret_cast<char *>(
|
||||
std::aligned_alloc(std::max(alignof(detail::ControlBlock), alignment),
|
||||
padded_cb_size + sizeof(T)));
|
||||
std::aligned_alloc(total_alignment, aligned_total_size));
|
||||
if (!buf) {
|
||||
std::fprintf(stderr, "Out of memory\n");
|
||||
std::abort();
|
||||
|
||||
Reference in New Issue
Block a user