diff -r 8cf78260b898 boost/multi_array.hpp
--- a/boost/multi_array.hpp	Fri Apr 06 10:04:40 2007 -0400
+++ b/boost/multi_array.hpp	Thu Apr 19 07:01:49 2007 -0400
@@ -36,6 +36,11 @@
 
 
 
+namespace std {
+  template<typename T>
+  class complex;
+};
+
 namespace boost {
   namespace detail {
     namespace multi_array {
@@ -48,6 +53,22 @@ namespace boost {
           return multi_array_types::index_range(base,base+extent_);
         }
       };
+
+      // specialisation which define whether a type has a trivial constructor
+      // or not. This is used by array types.
+      template<typename T>
+      struct has_trivial_constructor : public boost::has_trivial_constructor<T> {};
+
+      template<typename T>
+      struct has_trivial_destructor : public boost::has_trivial_destructor<T> {};
+
+      template<typename FLT>
+      struct has_trivial_constructor<std::complex<FLT> > : public boost::true_type {};
+        
+      template<typename FLT>
+      struct has_trivial_destructor<std::complex<FLT> > : public boost::true_type {};
+
+
 
 #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
 //
@@ -207,7 +228,7 @@ public:
 
   multi_array(const multi_array& rhs) :
   super_type(rhs), allocator_(rhs.allocator_) {
-    allocate_space();
+    allocate_space (false);
     boost::detail::multi_array::copy_n(rhs.base_,rhs.num_elements(),base_);
   }
 
@@ -226,7 +247,7 @@ public:
               const general_storage_order<NumDims>& so = c_storage_order())
     : super_type(0,so,rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     // Warning! storage order may change, hence the following copy technique.
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
@@ -237,7 +258,7 @@ public:
               const general_storage_order<NumDims>& so = c_storage_order())
     : super_type(0,so,rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
 
@@ -248,7 +269,7 @@ public:
               const general_storage_order<NumDims>& so = c_storage_order())
     : super_type(0,so,rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
 
@@ -259,7 +280,7 @@ public:
   multi_array(const const_multi_array_ref<T,NumDims>& rhs)
     : super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     // Warning! storage order may change, hence the following copy technique.
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
@@ -268,7 +289,7 @@ public:
               const general_storage_order<NumDims>& so)
     : super_type(0,so,rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     // Warning! storage order may change, hence the following copy technique.
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
@@ -277,7 +298,7 @@ public:
               const_sub_array<T,NumDims>& rhs)
     : super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
 
@@ -286,7 +307,7 @@ public:
               const general_storage_order<NumDims>& so)
     : super_type(0,so,rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
 
@@ -295,7 +316,7 @@ public:
               const_multi_array_view<T,NumDims>& rhs)
     : super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
 
@@ -304,7 +325,7 @@ public:
               const general_storage_order<NumDims>& so)
     : super_type(0,so,rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
 
@@ -314,7 +335,7 @@ public:
   multi_array(const multi_array_ref<T,NumDims>& rhs)
     : super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     // Warning! storage order may change, hence the following copy technique.
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
@@ -323,7 +344,7 @@ public:
               const general_storage_order<NumDims>& so)
     : super_type(0,so,rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     // Warning! storage order may change, hence the following copy technique.
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
@@ -333,7 +354,7 @@ public:
               sub_array<T,NumDims>& rhs)
     : super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
 
@@ -342,7 +363,7 @@ public:
               const general_storage_order<NumDims>& so)
     : super_type(0,so,rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
 
@@ -351,7 +372,7 @@ public:
               multi_array_view<T,NumDims>& rhs)
     : super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
     
@@ -360,7 +381,7 @@ public:
               const general_storage_order<NumDims>& so)
     : super_type(0,so,rhs.index_bases(),rhs.shape()) 
   {
-    allocate_space();
+    allocate_space (false);
     std::copy(rhs.begin(),rhs.end(),this->begin());
   }
     
@@ -469,24 +490,29 @@ public:
   }
 
 private:
-  void allocate_space() {
+  void allocate_space(bool do_alloc=default_do_alloc, T const& init=T()) {
     typename Allocator::const_pointer no_hint=0;
     base_ = allocator_.allocate(this->num_elements(),no_hint);
     this->set_base_ptr(base_);
     allocated_elements_ = this->num_elements();
-    std::uninitialized_fill_n(base_,allocated_elements_,T());
+    if (do_alloc)
+      std::uninitialized_fill_n(base_,allocated_elements_,T());
   }
 
   void deallocate_space() {
     if(base_) {
-      for(T* i = base_; i != base_+allocated_elements_; ++i)
-        allocator_.destroy(i);
+      if (!detail::multi_array::has_trivial_destructor<T>::value) {
+	for(T* i = base_; i != base_+allocated_elements_; ++i)
+	  allocator_.destroy(i);
+      }
       allocator_.deallocate(base_,allocated_elements_);
     }
   }
 
   typedef boost::array<size_type,NumDims> size_list;
   typedef boost::array<index,NumDims> index_list;
+
+  BOOST_STATIC_CONSTANT(bool, default_do_alloc = !detail::multi_array::has_trivial_constructor<T>::value);
 
   Allocator allocator_;
   T* base_;

