Fixing whitespace problems
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@111767 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// raw_storage_iterator
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
int A_constructed = 0;
|
||||
|
||||
struct A
|
||||
{
|
||||
int data_;
|
||||
public:
|
||||
explicit A(int i) : data_(i) {++A_constructed;}
|
||||
|
||||
A(const A& a) : data_(a.data_) {++A_constructed;}
|
||||
~A() {--A_constructed; data_ = 0;}
|
||||
|
||||
bool operator==(int i) const {return data_ == i;}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::aligned_storage<3*sizeof(A), std::alignment_of<A>::value>::type
|
||||
Storage;
|
||||
Storage buffer;
|
||||
std::raw_storage_iterator<A*, A> it((A*)&buffer);
|
||||
assert(A_constructed == 0);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
*it++ = A(i+1);
|
||||
A* ap = (A*)&buffer + i;
|
||||
assert(*ap == i+1);
|
||||
assert(A_constructed == i+1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user