From 77874ee51825e070035809a8d81162f026e62b55 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sat, 14 Sep 2013 19:24:38 -0700 Subject: [PATCH] Use new instead of ::new for placement --- .../beast_asio/async/SharedHandlerAllocator.h | 2 +- modules/beast_asio/async/SharedHandlerType.h | 14 +------------- modules/beast_core/containers/DynamicArray.h | 18 +++++++++--------- modules/beast_core/containers/DynamicList.h | 14 +++++++------- modules/beast_core/functional/SharedFunction.h | 4 ++-- modules/beast_core/memory/SharedSingleton.h | 2 +- modules/beast_core/memory/StaticObject.h | 2 +- .../beast_core/thread/impl/TrackedMutex.cpp | 2 +- 8 files changed, 23 insertions(+), 35 deletions(-) diff --git a/modules/beast_asio/async/SharedHandlerAllocator.h b/modules/beast_asio/async/SharedHandlerAllocator.h index 86d894e95..41606f456 100644 --- a/modules/beast_asio/async/SharedHandlerAllocator.h +++ b/modules/beast_asio/async/SharedHandlerAllocator.h @@ -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 diff --git a/modules/beast_asio/async/SharedHandlerType.h b/modules/beast_asio/async/SharedHandlerType.h index 89d9f3c4d..77961ce2c 100644 --- a/modules/beast_asio/async/SharedHandlerType.h +++ b/modules/beast_asio/async/SharedHandlerType.h @@ -97,18 +97,6 @@ protected: deallocate (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 * newSharedHandlerContainer (BOOST_ASIO_MOVE_ARG(Handler) han Handler local (BOOST_ASIO_MOVE_CAST(Handler)(handler)); void* const p (boost_asio_handler_alloc_helpers:: allocate (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 diff --git a/modules/beast_core/containers/DynamicArray.h b/modules/beast_core/containers/DynamicArray.h index 70a079cae..82aeb08cf 100644 --- a/modules/beast_core/containers/DynamicArray.h +++ b/modules/beast_core/containers/DynamicArray.h @@ -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 iterator emplace_back (A1 a1) { - ::new (alloc ()) T (a1); + new (alloc ()) T (a1); return iterator (this, size () - 1); } template iterator emplace_back (A1 a1, A2 a2) { - ::new (alloc ()) T (a1, a2); + new (alloc ()) T (a1, a2); return iterator (this, size () - 1); } template 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 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 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 (); diff --git a/modules/beast_core/containers/DynamicList.h b/modules/beast_core/containers/DynamicList.h index e048774c7..d3768239b 100644 --- a/modules/beast_core/containers/DynamicList.h +++ b/modules/beast_core/containers/DynamicList.h @@ -367,43 +367,43 @@ public: */ iterator emplace_back () { - return iterator_to (*::new (alloc ()->get ()) T ()); + return iterator_to (*new (alloc ()->get ()) T ()); } template iterator emplace_back (A1 a1) { - return iterator_to (*::new (alloc ()->get ()) T (a1)); + return iterator_to (*new (alloc ()->get ()) T (a1)); } template 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 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 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 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. */ diff --git a/modules/beast_core/functional/SharedFunction.h b/modules/beast_core/functional/SharedFunction.h index 937942c92..693982da1 100644 --- a/modules/beast_core/functional/SharedFunction.h +++ b/modules/beast_core/functional/SharedFunction.h @@ -69,7 +69,7 @@ public: template SharedFunction (F f, A a = A ()) - : m_ptr (::new ( + : m_ptr (new ( typename CallType ::Allocator (a) .allocate (sizeof (CallType ))) CallType (BEAST_MOVE_CAST(F)(f), a)) @@ -152,7 +152,7 @@ public: template SharedFunction (F f, A a = A ()) - : m_ptr (::new ( + : m_ptr (new ( typename CallType ::Allocator (a) .allocate (sizeof (CallType ))) CallType (BEAST_MOVE_CAST(F)(f), a)) diff --git a/modules/beast_core/memory/SharedSingleton.h b/modules/beast_core/memory/SharedSingleton.h index 895f266d9..14ab7c0ce 100644 --- a/modules/beast_core/memory/SharedSingleton.h +++ b/modules/beast_core/memory/SharedSingleton.h @@ -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; } } diff --git a/modules/beast_core/memory/StaticObject.h b/modules/beast_core/memory/StaticObject.h index c602e5738..29f16d9e1 100644 --- a/modules/beast_core/memory/StaticObject.h +++ b/modules/beast_core/memory/StaticObject.h @@ -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 diff --git a/modules/beast_core/thread/impl/TrackedMutex.cpp b/modules/beast_core/thread/impl/TrackedMutex.cpp index d37a14881..f76fa6aa9 100644 --- a/modules/beast_core/thread/impl/TrackedMutex.cpp +++ b/modules/beast_core/thread/impl/TrackedMutex.cpp @@ -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); }