1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// UNSUPPORTED: c++98, c++03
11
12// <memory>
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 <memory>
23#include <cassert>
24
25struct alignas(32) A {
26    int field;
27};
28
29int main()
30{
31    std::pair<A*, std::ptrdiff_t> ip = std::get_temporary_buffer<A>(5);
32    assert(!(ip.first == nullptr) ^ (ip.second == 0));
33    assert(reinterpret_cast<uintptr_t>(ip.first) % alignof(A) == 0);
34    std::return_temporary_buffer(ip.first);
35}
36