MySQL 8.4.2
Source Code Documentation
ut0new.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2020, 2024, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is designed to work with certain software (including
10but not limited to OpenSSL) that is licensed under separate terms,
11as designated in a particular file or component or in included license
12documentation. The authors of MySQL hereby grant you an additional
13permission to link the program and your derivative works with the
14separately licensed software that they have either included with
15the program or referenced in the documentation.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 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
41
42namespace ut {
43namespace detail {
44
45template <typename T, typename Tuple, size_t... Args_index_seq>
46inline 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
52template <typename T, typename Tuple>
53inline 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 */
Implementation bits and pieces for aligned allocations.
Implementation bits and pieces for PFS and non-PFS variants for normal allocations and deallocations ...
Implementation bits and pieces for large (huge) page allocations.
Definition: ut0tuple.h:57
void construct_impl(void *mem, size_t offset, Tuple &&tuple, std::index_sequence< Args_index_seq... >)
Definition: ut0new.h:46
void construct(void *mem, size_t offset, Tuple &&tuple)
Definition: ut0new.h:53
This file contains a set of libraries providing overloads for regular dynamic allocation routines whi...
Definition: aligned_alloc.h:48
Implementation bits and pieces for page-aligned allocations.
static MEM_ROOT mem
Definition: sql_servers.cc:100