Use new instead of ::new for placement

This commit is contained in:
Vinnie Falco
2013-09-14 19:24:38 -07:00
parent 2a04dcc334
commit 77874ee518
8 changed files with 23 additions and 35 deletions

View File

@@ -94,7 +94,7 @@ struct SharedHandlerAllocator
void construct (pointer p, const_reference val) const
{
::new ((void *)p) value_type (val);
new ((void *)p) value_type (val);
}
void destroy (pointer p) const

View File

@@ -97,18 +97,6 @@ protected:
deallocate <Handler> (shared, size, local);
}
// If these somehow get called, bad things will happen
//
void* operator new (std::size_t)
{
return pure_virtual_called (__FILE__, __LINE__);
}
void operator delete (void*)
{
return pure_virtual_called (__FILE__, __LINE__);
}
protected:
std::size_t const m_size;
Handler mutable m_handler;
@@ -218,7 +206,7 @@ Container <Handler>* newSharedHandlerContainer (BOOST_ASIO_MOVE_ARG(Handler) han
Handler local (BOOST_ASIO_MOVE_CAST(Handler)(handler));
void* const p (boost_asio_handler_alloc_helpers::
allocate <Handler> (size, local));
return ::new (p) ContainerType (size, BOOST_ASIO_MOVE_CAST(Handler)(local));
return new (p) ContainerType (size, BOOST_ASIO_MOVE_CAST(Handler)(local));
}
#endif

View File

@@ -618,48 +618,48 @@ public:
iterator push_back (TParam value)
{
::new (alloc ()) T (value);
new (alloc ()) T (value);
return iterator (this, size () - 1);
}
iterator emplace_back ()
{
::new (alloc ()) T ();
new (alloc ()) T ();
return iterator (this, size () - 1);
}
template <class A1>
iterator emplace_back (A1 a1)
{
::new (alloc ()) T (a1);
new (alloc ()) T (a1);
return iterator (this, size () - 1);
}
template <class A1, class A2>
iterator emplace_back (A1 a1, A2 a2)
{
::new (alloc ()) T (a1, a2);
new (alloc ()) T (a1, a2);
return iterator (this, size () - 1);
}
template <class A1, class A2, class A3>
iterator emplace_back (A1 a1, A2 a2, A3 a3)
{
::new (alloc ()) T (a1, a2, a3);
new (alloc ()) T (a1, a2, a3);
return iterator (this, size () - 1);
}
template <class A1, class A2, class A3, class A4>
iterator emplace_back (A1 a1, A2 a2, A3 a3, A4 a4)
{
::new (alloc ()) T (a1, a2, a3, a4);
new (alloc ()) T (a1, a2, a3, a4);
return iterator (this, size () - 1);
}
template <class A1, class A2, class A3, class A4, class A5>
iterator emplace_back (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
{
::new (alloc ()) T (a1, a2, a3, a4, a5);
new (alloc ()) T (a1, a2, a3, a4, a5);
return iterator (this, size () - 1);
}
@@ -671,7 +671,7 @@ public:
void resize (size_type count)
{
while (count > size ())
::new (alloc ()) T;
new (alloc ()) T;
while (count < size ())
get (--m_size).~T ();
@@ -680,7 +680,7 @@ public:
void resize (size_type count, TParam value)
{
while (count > size ())
::new (alloc ()) T (value);
new (alloc ()) T (value);
while (count < size ())
get (--m_size).~T ();

View File

@@ -367,43 +367,43 @@ public:
*/
iterator emplace_back ()
{
return iterator_to (*::new (alloc ()->get ()) T ());
return iterator_to (*new (alloc ()->get ()) T ());
}
template <class A1>
iterator emplace_back (A1 a1)
{
return iterator_to (*::new (alloc ()->get ()) T (a1));
return iterator_to (*new (alloc ()->get ()) T (a1));
}
template <class A1, class A2>
iterator emplace_back (A1 a1, A2 a2)
{
return iterator_to (*::new (alloc ()->get ()) T (a1, a2));
return iterator_to (*new (alloc ()->get ()) T (a1, a2));
}
template <class A1, class A2, class A3>
iterator emplace_back (A1 a1, A2 a2, A3 a3)
{
return iterator_to (*::new (alloc ()->get ()) T (a1, a2, a3));
return iterator_to (*new (alloc ()->get ()) T (a1, a2, a3));
}
template <class A1, class A2, class A3, class A4>
iterator emplace_back (A1 a1, A2 a2, A3 a3, A4 a4)
{
return iterator_to (*::new (alloc ()->get ()) T (a1, a2, a3, a4));
return iterator_to (*new (alloc ()->get ()) T (a1, a2, a3, a4));
}
template <class A1, class A2, class A3, class A4, class A5>
iterator emplace_back (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
{
return iterator_to (*::new (alloc ()->get ()) T (a1, a2, a3, a4, a5));
return iterator_to (*new (alloc ()->get ()) T (a1, a2, a3, a4, a5));
}
/** Allocate a new copy-constructed element and return the index. */
iterator push_back (TParam value) noexcept
{
return iterator_to (*::new (alloc ()->get ()) T (value));
return iterator_to (*new (alloc ()->get ()) T (value));
}
/** Erase the element at the specified position. */

View File

@@ -69,7 +69,7 @@ public:
template <typename F>
SharedFunction (F f, A a = A ())
: m_ptr (::new (
: m_ptr (new (
typename CallType <F>::Allocator (a)
.allocate (sizeof (CallType <F>)))
CallType <F> (BEAST_MOVE_CAST(F)(f), a))
@@ -152,7 +152,7 @@ public:
template <typename F>
SharedFunction (F f, A a = A ())
: m_ptr (::new (
: m_ptr (new (
typename CallType <F>::Allocator (a)
.allocate (sizeof (CallType <F>)))
CallType <F> (BEAST_MOVE_CAST(F)(f), a))

View File

@@ -88,7 +88,7 @@ public:
{
bassert (lifetime == SingletonLifetime::createOnDemand || ! staticData.destructorCalled);
staticData.instance = &staticData.object;
::new (staticData.instance) SharedSingleton (lifetime);
new (staticData.instance) SharedSingleton (lifetime);
instance = staticData.instance;
}
}

View File

@@ -150,7 +150,7 @@ public:
if (staticData.state.compareAndSetBool (initializing, uninitialized))
{
// Initialize the object.
::new (&staticData.object) Object;
new (&staticData.object) Object;
staticData.state = initialized;
}
else

View File

@@ -50,7 +50,7 @@ TrackedMutexBasics::PerThreadData& TrackedMutexBasics::getPerThreadData ()
// Manually call the constructor with placement new if needed
if (! thread.id)
{
::new (&thread) PerThreadData ();
new (&thread) PerThreadData ();
bassert (thread.id != 0);
}