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 // UNSUPPORTED: c++98, c++03
10 
11 // <memory>
12 
13 // template <class T>
14 //   pair<T*, ptrdiff_t>
15 //   get_temporary_buffer(ptrdiff_t n);
16 //
17 // template <class T>
18 //   void
19 //   return_temporary_buffer(T* p);
20 
21 #include <memory>
22 #include <cassert>
23 
24 #include "test_macros.h"
25 
26 struct alignas(32) A {
27     int field;
28 };
29 
30 int main(int, char**)
31 {
32     std::pair<A*, std::ptrdiff_t> ip = std::get_temporary_buffer<A>(5);
33     assert(!(ip.first == nullptr) ^ (ip.second == 0));
34     assert(reinterpret_cast<uintptr_t>(ip.first) % alignof(A) == 0);
35     std::return_temporary_buffer(ip.first);
36 
37   return 0;
38 }
39