Tidy up calls to placement new

This commit is contained in:
Vinnie Falco
2018-12-02 19:48:42 -08:00
parent 397c388e18
commit b3a8e6edb5
5 changed files with 14 additions and 6 deletions
+3 -2
View File
@@ -181,7 +181,7 @@ alloc(std::size_t n)
if(end >= buf_ && end +
sizeof(element) + n <= buf_ + size_)
{
auto& e = *new(end) element{n, used};
auto& e = *::new(end) element{n, used};
list_.push_back(e);
high_ = (std::max)(high_, used);
return e.data();
@@ -300,7 +300,8 @@ public:
void
construct(U* ptr, Args&&... args)
{
::new((void*)ptr) U(std::forward<Args>(args)...);
::new(static_cast<void*>(ptr)) U(
std::forward<Args>(args)...);
}
template<class U>
+3 -2
View File
@@ -43,7 +43,7 @@ public:
construct(std::size_t size)
{
auto p = new char[sizeof(static_pool) + size];
return *(new(p) static_pool{size});
return *(::new(p) static_pool{size});
}
static_pool&
@@ -169,7 +169,8 @@ public:
void
construct(U* ptr, Args&&... args)
{
::new((void*)ptr) U(std::forward<Args>(args)...);
::new(static_cast<void*>(ptr)) U(
std::forward<Args>(args)...);
}
template<class U>