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 struct alignas(32) A {
25     int field;
26 };
27 
28 int main(int, char**)
29 {
30     std::pair<A*, std::ptrdiff_t> ip = std::get_temporary_buffer<A>(5);
31     assert(!(ip.first == nullptr) ^ (ip.second == 0));
32     assert(reinterpret_cast<uintptr_t>(ip.first) % alignof(A) == 0);
33     std::return_temporary_buffer(ip.first);
34 
35   return 0;
36 }
37