Implement LWG2433: uninitialized_copy()/etc. should tolerate overloaded operator&
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@237699 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -28,8 +28,19 @@ struct B
|
||||
|
||||
int B::count_ = 0;
|
||||
|
||||
struct Nasty
|
||||
{
|
||||
Nasty() : i_ ( counter_++ ) {}
|
||||
Nasty * operator &() const { return NULL; }
|
||||
int i_;
|
||||
static int counter_;
|
||||
};
|
||||
|
||||
int Nasty::counter_ = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
const int N = 5;
|
||||
char pool[sizeof(B)*N] = {0};
|
||||
B* bp = (B*)pool;
|
||||
@@ -47,4 +58,15 @@ int main()
|
||||
std::uninitialized_fill(bp, bp+2, B());
|
||||
for (int i = 0; i < 2; ++i)
|
||||
assert(bp[i].data_ == 1);
|
||||
}
|
||||
{
|
||||
const int N = 5;
|
||||
char pool[N*sizeof(Nasty)] = {0};
|
||||
Nasty* bp = (Nasty*)pool;
|
||||
|
||||
Nasty::counter_ = 23;
|
||||
std::uninitialized_fill(bp, bp+N, Nasty());
|
||||
for (int i = 0; i < N; ++i)
|
||||
assert(bp[i].i_ == 23);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user