[NFC] Maintainers.rst: align email address formatting
[llvm-project.git] / libcxx / include / __memory / temporary_buffer.h
blobd18717f52d1cddcf2f99e931271482127010e0ad
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___MEMORY_TEMPORARY_BUFFER_H
11 #define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H
13 #include <__config>
14 #include <__cstddef/ptrdiff_t.h>
15 #include <__memory/unique_temporary_buffer.h>
16 #include <__utility/pair.h>
18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19 # pragma GCC system_header
20 #endif
22 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER)
24 _LIBCPP_BEGIN_NAMESPACE_STD
26 template <class _Tp>
27 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptrdiff_t>
28 get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT {
29 __unique_temporary_buffer<_Tp> __unique_buf = std::__allocate_unique_temporary_buffer<_Tp>(__n);
30 pair<_Tp*, ptrdiff_t> __result(__unique_buf.get(), __unique_buf.get_deleter().__count_);
31 __unique_buf.release();
32 return __result;
35 template <class _Tp>
36 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 void return_temporary_buffer(_Tp* __p) _NOEXCEPT {
37 __unique_temporary_buffer<_Tp> __unique_buf(__p);
38 (void)__unique_buf;
41 _LIBCPP_END_NAMESPACE_STD
43 #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER)
45 #endif // _LIBCPP___MEMORY_TEMPORARY_BUFFER_H