mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 01:18:52 +08:00

Patch by Chris Kennelly! Differential Revision: https://reviews.llvm.org/D41746 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324020 91177308-0d34-0410-b5e6-96231b3b80d8
34 lines
864 B
C++
34 lines
864 B
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
// Source Licenses. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// <memory>
|
|
|
|
// template <class T>
|
|
// pair<T*, ptrdiff_t>
|
|
// get_temporary_buffer(ptrdiff_t n);
|
|
//
|
|
// template <class T>
|
|
// void
|
|
// return_temporary_buffer(T* p);
|
|
|
|
#include <memory>
|
|
#include <cassert>
|
|
|
|
struct alignas(32) A {
|
|
int field;
|
|
};
|
|
|
|
int main()
|
|
{
|
|
std::pair<A*, std::ptrdiff_t> ip = std::get_temporary_buffer<A>(5);
|
|
assert(!(ip.first == nullptr) ^ (ip.second == 0));
|
|
assert(reinterpret_cast<uintptr_t>(ip.first) % alignof(A) == 0);
|
|
std::return_temporary_buffer(ip.first);
|
|
}
|