File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* mbed Microcontroller Library
2
+ * Copyright (c) 2019 ARM Limited
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ #ifndef MSTD_NEW_
18
+ #define MSTD_NEW_
19
+
20
+ /* <mstd_new>
21
+ *
22
+ * - includes toolchain's <new>
23
+ * - For all toolchains, C++17 backports:
24
+ * - mstd::launder
25
+ */
26
+
27
+ #include <new>
28
+ #if __cpp_lib_launder < 201606
29
+ #include <type_traits>
30
+ #endif
31
+
32
+ namespace mstd
33
+ {
34
+ using std::nothrow_t;
35
+ using std::nothrow;
36
+ using std::new_handler;
37
+ using std::set_new_handler;
38
+
39
+ #if __cpp_lib_launder >= 201606
40
+ using std::launder;
41
+ #else
42
+ template <typename T>
43
+ constexpr T *launder(T *p) noexcept
44
+ {
45
+ static_assert(!std::is_function<T>::value && !std::is_void<T>::value, "Can only launder complete object types");
46
+ #if defined __clang__ || __GNUC__ >= 9
47
+ return __builtin_launder(p);
48
+ #else
49
+ return p;
50
+ #endif
51
+ }
52
+ #endif
53
+
54
+ } // namespace mstd
55
+
56
+ #endif // MSTD_NEW_
You can’t perform that action at this time.
0 commit comments