| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // <memory> |
| 10 | |
| 11 | // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER |
| 12 | // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS |
| 13 | |
| 14 | // template <class T> |
| 15 | // pair<T*, ptrdiff_t> |
| 16 | // get_temporary_buffer(ptrdiff_t n); |
| 17 | // |
| 18 | // template <class T> |
| 19 | // void |
| 20 | // return_temporary_buffer(T* p); |
| 21 | |
| 22 | #include <cassert> |
| 23 | #include <cstddef> |
| 24 | #include <memory> |
| 25 | #include <utility> |
| 26 | |
| 27 | int main(int, char**) |
| 28 | { |
| 29 | std::pair<int*, std::ptrdiff_t> ip = std::get_temporary_buffer<int>(len: 5); |
| 30 | assert(ip.first); |
| 31 | assert(ip.second == 5); |
| 32 | std::return_temporary_buffer(p: ip.first); |
| 33 | |
| 34 | return 0; |
| 35 | } |
| 36 | |