This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] libstdc++/25626: valarray vs non-POD


Paolo Carlini wrote:

>The gslice_array bits are not ok: _M_data is private. I'm looking into this.
>  
>
I can deal with this problem taking another small bit from Gaby's big draft.

Still ABI-safe and non-invasive.

Paolo.

////////////////
2006-01-13  Paolo Carlini  <pcarlini@suse.de>
	    Gabriel Dos Reis  <gdr@integrable-solutions.net>

	PR libstdc++/25626
	* include/std/std_valarray.h (valarray(const slice_array<>&),
	valarray(const gslice_array<>&), valarray(const mask_array<>&),
	valarray(const indirect_array<>&), valarray(const _Expr<>&)):
	Forward to __valarray_copy_construct, not __valarray_copy.
	(__values()): New.
Index: include/std/std_valarray.h
===================================================================
--- include/std/std_valarray.h	(revision 109673)
+++ include/std/std_valarray.h	(working copy)
@@ -1,6 +1,6 @@
 // The template and inlines for the -*- C++ -*- valarray class.
 
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -512,14 +512,21 @@
        */
       void resize(size_t __size, _Tp __c = _Tp());
 
+      // Return handle to the internal data help by this valarray.
+      _Tp* __restrict__ __values() const;
+
     private:
       size_t _M_size;
       _Tp* __restrict__ _M_data;
       
       friend class _Array<_Tp>;
     };
-  
+
   template<typename _Tp>
+    inline _Tp* __restrict__
+    valarray<_Tp>::__values() const { return _M_data; }
+
+  template<typename _Tp>
     inline const _Tp&
     valarray<_Tp>::operator[](size_t __i) const
     { 
@@ -583,8 +590,8 @@
     valarray<_Tp>::valarray(const slice_array<_Tp>& __sa)
     : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz))
     {
-      std::__valarray_copy
-	(__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data));
+      std::__valarray_copy_construct
+	(__sa._M_array._M_data, __sa._M_sz, __sa._M_stride, _M_data);
     }
 
   template<typename _Tp>
@@ -593,9 +600,8 @@
     : _M_size(__ga._M_index.size()),
       _M_data(__valarray_get_storage<_Tp>(_M_size))
     {
-      std::__valarray_copy
-	(__ga._M_array, _Array<size_t>(__ga._M_index),
-	 _Array<_Tp>(_M_data), _M_size);
+      std::__valarray_copy_construct
+	(__ga._M_array._M_data, __ga._M_index.__values(), _M_data, _M_size);
     }
 
   template<typename _Tp>
@@ -603,7 +609,7 @@
     valarray<_Tp>::valarray(const mask_array<_Tp>& __ma)
     : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz))
     {
-      std::__valarray_copy
+      std::__valarray_copy_construct
 	(__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size);
     }
 
@@ -612,15 +618,15 @@
     valarray<_Tp>::valarray(const indirect_array<_Tp>& __ia)
     : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz))
     {
-      std::__valarray_copy
-	(__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size);
+      std::__valarray_copy_construct
+	(__ia._M_array._M_data, __ia._M_index._M_data, _M_data, _M_size);
     }
 
   template<typename _Tp> template<class _Dom>
     inline
     valarray<_Tp>::valarray(const _Expr<_Dom, _Tp>& __e)
     : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size))
-    { std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); }
+    { std::__valarray_copy_construct(__e, _M_size, _Array<_Tp>(_M_data)); }
 
   template<typename _Tp>
     inline

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]