| 1 |
/***************************************************************************** |
| 2 |
|
| 3 |
Copyright (c) 2020, 2026, Oracle and/or its affiliates. |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or modify it under |
| 6 |
the terms of the GNU General Public License, version 2.0, as published by the |
| 7 |
Free Software Foundation. |
| 8 |
|
| 9 |
This program is designed to work with certain software (including |
| 10 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 11 |
as designated in a particular file or component or in included license |
| 12 |
documentation. The authors of MySQL hereby grant you an additional |
| 13 |
permission to link the program and your derivative works with the |
| 14 |
separately licensed software that they have either included with |
| 15 |
the program or referenced in the documentation. |
| 16 |
|
| 17 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, |
| 20 |
for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License along with |
| 23 |
this program; if not, write to the Free Software Foundation, Inc., |
| 24 |
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 |
|
| 26 |
*****************************************************************************/ |
| 27 |
|
| 28 |
/** @file include/detail/ut0new.h |
| 29 |
Implementation bits and pieces of include/ut0new.h */ |
| 30 |
|
| 31 |
#ifndef detail_ut0new_h |
| 32 |
#define detail_ut0new_h |
| 33 |
|
| 34 |
#include <cstddef> |
| 35 |
#include <utility> |
| 36 |
|
| 37 |
#include "storage/innobase/include/detail/ut/aligned_alloc.h" |
| 38 |
#include "storage/innobase/include/detail/ut/alloc.h" |
| 39 |
#include "storage/innobase/include/detail/ut/large_page_alloc.h" |
| 40 |
#include "storage/innobase/include/detail/ut/page_alloc.h" |
| 41 |
|
| 42 |
namespace ut { |
| 43 |
namespace detail { |
| 44 |
|
| 45 |
template <typename T, typename Tuple, size_t... Args_index_seq> |
| 46 |
inline void construct_impl(void *mem, size_t offset, Tuple &&tuple, |
| 47 |
std::index_sequence<Args_index_seq...>) { |
| 48 |
new (reinterpret_cast<uint8_t *>(mem) + offset) |
| 49 |
T{std::get<Args_index_seq>(std::forward<Tuple>(tuple))...}; |
| 50 |
} |
| 51 |
|
| 52 |
template <typename T, typename Tuple> |
| 53 |
inline void construct(void *mem, size_t offset, Tuple &&tuple) { |
| 54 |
using N_args_seq = std::make_index_sequence<std::tuple_size<Tuple>::value>; |
| 55 |
construct_impl<T>(mem, offset, tuple, N_args_seq{}); |
| 56 |
} |
| 57 |
|
| 58 |
} // namespace detail |
| 59 |
} // namespace ut |
| 60 |
|
| 61 |
#endif /* detail_ut0new_h */ |