|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85011 - trunk/boost/lockfree
From: tim_at_[hidden]
Date: 2013-07-12 13:47:42
Author: timblechmann
Date: 2013-07-12 13:47:42 EDT (Fri, 12 Jul 2013)
New Revision: 85011
URL: http://svn.boost.org/trac/boost/changeset/85011
Log:
lockfree: spsc queue - use std::copy if possible
Text files modified:
trunk/boost/lockfree/spsc_queue.hpp | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
Modified: trunk/boost/lockfree/spsc_queue.hpp
==============================================================================
--- trunk/boost/lockfree/spsc_queue.hpp Fri Jul 12 13:46:42 2013 (r85010)
+++ trunk/boost/lockfree/spsc_queue.hpp 2013-07-12 13:47:42 EDT (Fri, 12 Jul 2013) (r85011)
@@ -20,6 +20,8 @@
#include <boost/static_assert.hpp>
#include <boost/utility.hpp>
+#include <boost/type_traits/has_trivial_destructor.hpp>
+
#include <boost/lockfree/detail/atomic.hpp>
#include <boost/lockfree/detail/branch_hints.hpp>
#include <boost/lockfree/detail/parameter.hpp>
@@ -287,11 +289,15 @@
template< class OutputIterator >
OutputIterator copy_and_delete( T * first, T * last, OutputIterator out )
{
- for (; first != last; ++first, ++out) {
- *out = *first;
- first->~T();
- }
- return out;
+ if (boost::has_trivial_destructor<T>::value) {
+ return std::copy(first, last, out); // will use memcpy if possible
+ } else {
+ for (; first != last; ++first, ++out) {
+ *out = *first;
+ first->~T();
+ }
+ return out;
+ }
}
};
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk