$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r81749 - trunk/boost/smart_ptr/detail
From: glenfe_at_[hidden]
Date: 2012-12-06 22:10:23
Author: glenfe
Date: 2012-12-06 22:10:22 EST (Thu, 06 Dec 2012)
New Revision: 81749
URL: http://svn.boost.org/trac/boost/changeset/81749
Log:
Special case array construction for trivially default-constructible types and array destruction for trivially-destroyable types.
Text files modified: 
   trunk/boost/smart_ptr/detail/array_utility.hpp |    28 ++++++++++++++++++++++++++++            
   1 files changed, 28 insertions(+), 0 deletions(-)
Modified: trunk/boost/smart_ptr/detail/array_utility.hpp
==============================================================================
--- trunk/boost/smart_ptr/detail/array_utility.hpp	(original)
+++ trunk/boost/smart_ptr/detail/array_utility.hpp	2012-12-06 22:10:22 EST (Thu, 06 Dec 2012)
@@ -17,12 +17,32 @@
     namespace detail {
         template<typename T>
         inline void array_destroy(T* memory, std::size_t size) {
+            boost::has_trivial_destructor<T> type;
+            array_destroy(memory, size, type);
+        }
+        template<typename T>
+        inline void array_destroy(T*, std::size_t, boost::true_type) {
+        }
+        template<typename T>
+        inline void array_destroy(T* memory, std::size_t size, boost::false_type) {
             for (std::size_t i = size; i > 0; ) {
                 memory[--i].~T();
             }
         }
         template<typename T>
         inline void array_construct(T* memory, std::size_t size) {
+            boost::has_trivial_default_constructor<T> type;            
+            array_construct(memory, size, type);
+        }
+        template<typename T>
+        inline void array_construct(T* memory, std::size_t size, boost::true_type) {
+            for (std::size_t i = 0; i < size; i++) {
+                void* p1 = memory + i;
+                ::new(p1) T();
+            }
+        }
+        template<typename T>
+        inline void array_construct(T* memory, std::size_t size, boost::false_type) {
             std::size_t i = 0;
             try {
                 for (; i < size; i++) {
@@ -92,6 +112,14 @@
         }
         template<typename T>
         inline void array_construct_noinit(T* memory, std::size_t size) {
+            boost::has_trivial_default_constructor<T> type;
+            array_construct_noinit(memory, size, type);
+        }
+        template<typename T>
+        inline void array_construct_noinit(T*, std::size_t, boost::true_type) {
+        }
+        template<typename T>
+        inline void array_construct_noinit(T* memory, std::size_t size, boost::false_type) {
             std::size_t i = 0;
             try {
                 for (; i < size; i++) {