aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2006-12-05 19:25:48 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2006-12-05 19:25:48 +0000
commita7e95a36ae03042318c834b30844bb22a8d66ce0 (patch)
tree9b800f96aaf5df5ba35a62b48ee1768f69197664 /libstdc++-v3
parent8bb2c2a29366f52c14bc6300dea64966823c95bc (diff)
2006-12-05 Paolo Carlini <pcarlini@suse.de>
DR 543, [Ready]. * include/bits/slice_array.h (slice::slice()): Implement the resolution. * include/bits/gslice.h (gslice::_Indexer::_Indexer()): Add. (gslice::gslice()): Use it. * testsuite/26_numerics/valarray/dr543.cc: New. * docs/html/ext/howto.html: Add an entry for DR 543. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119552 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog10
-rw-r--r--libstdc++-v3/docs/html/ext/howto.html6
-rw-r--r--libstdc++-v3/include/bits/gslice.h26
-rw-r--r--libstdc++-v3/include/bits/slice_array.h9
-rw-r--r--libstdc++-v3/testsuite/26_numerics/valarray/dr543.cc40
5 files changed, 79 insertions, 12 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 83ff9ad6e40..fd16bb44dd0 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,13 @@
+2006-12-05 Paolo Carlini <pcarlini@suse.de>
+
+ DR 543, [Ready].
+ * include/bits/slice_array.h (slice::slice()): Implement the
+ resolution.
+ * include/bits/gslice.h (gslice::_Indexer::_Indexer()): Add.
+ (gslice::gslice()): Use it.
+ * testsuite/26_numerics/valarray/dr543.cc: New.
+ * docs/html/ext/howto.html: Add an entry for DR 543.
+
2006-12-05 Benjamin Kosnik <bkoz@redhat.com>
* include/tr1/tuple: Consistent include guards.
diff --git a/libstdc++-v3/docs/html/ext/howto.html b/libstdc++-v3/docs/html/ext/howto.html
index 8d9bee14e60..800f286da59 100644
--- a/libstdc++-v3/docs/html/ext/howto.html
+++ b/libstdc++-v3/docs/html/ext/howto.html
@@ -594,6 +594,12 @@
input_iterator' value_type.
</dd>
+ <dt><a href="lwg-active.html#543">543</a>:
+ <em>valarray slice default constructor</em>
+ </dt>
+ <dd>Follow the straightforward proposed resolution.
+ </dd>
+
<dt><a href="lwg-active.html#586">586</a>:
<em>string inserter not a formatted function</em>
</dt>
diff --git a/libstdc++-v3/include/bits/gslice.h b/libstdc++-v3/include/bits/gslice.h
index 560aeb5e8c9..1afda4b407d 100644
--- a/libstdc++-v3/include/bits/gslice.h
+++ b/libstdc++-v3/include/bits/gslice.h
@@ -1,6 +1,6 @@
// The template and inlines for the -*- C++ -*- gslice class.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2004, 2005
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2004, 2005, 2006
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -64,7 +64,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
public:
/// Construct an empty slice.
- gslice ();
+ gslice();
/**
* @brief Construct a slice.
@@ -108,8 +108,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
valarray<size_t> _M_size;
valarray<size_t> _M_stride;
valarray<size_t> _M_index; // Linear array of referenced indices
+
+ _Indexer()
+ : _M_count(1), _M_start(0), _M_size(), _M_stride(), _M_index() {}
+
_Indexer(size_t, const valarray<size_t>&,
const valarray<size_t>&);
+
void
_M_increment_use()
{ ++_M_count; }
@@ -125,18 +130,22 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
};
inline size_t
- gslice::start () const
+ gslice::start() const
{ return _M_index ? _M_index->_M_start : 0; }
inline valarray<size_t>
- gslice::size () const
+ gslice::size() const
{ return _M_index ? _M_index->_M_size : valarray<size_t>(); }
inline valarray<size_t>
- gslice::stride () const
+ gslice::stride() const
{ return _M_index ? _M_index->_M_stride : valarray<size_t>(); }
- inline gslice::gslice () : _M_index(0) {}
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 543. valarray slice default constructor
+ inline
+ gslice::gslice()
+ : _M_index(new gslice::_Indexer()) {}
inline
gslice::gslice(size_t __o, const valarray<size_t>& __l,
@@ -144,7 +153,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
: _M_index(new gslice::_Indexer(__o, __l, __s)) {}
inline
- gslice::gslice(const gslice& __g) : _M_index(__g._M_index)
+ gslice::gslice(const gslice& __g)
+ : _M_index(__g._M_index)
{ if (_M_index) _M_index->_M_increment_use(); }
inline
@@ -155,7 +165,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
}
inline gslice&
- gslice::operator= (const gslice& __g)
+ gslice::operator=(const gslice& __g)
{
if (__g._M_index)
__g._M_index->_M_increment_use();
diff --git a/libstdc++-v3/include/bits/slice_array.h b/libstdc++-v3/include/bits/slice_array.h
index 41debfe5539..d9ffad5b0fa 100644
--- a/libstdc++-v3/include/bits/slice_array.h
+++ b/libstdc++-v3/include/bits/slice_array.h
@@ -1,6 +1,6 @@
// The template and inlines for the -*- C++ -*- slice_array 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
@@ -83,10 +83,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
size_t _M_st; // stride unit
};
- // The default constructor constructor is not required to initialize
- // data members with any meaningful values, so we choose to do nothing.
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 543. valarray slice default constructor
inline
- slice::slice() {}
+ slice::slice()
+ : _M_off(0), _M_sz(0), _M_st(0) {}
inline
slice::slice(size_t __o, size_t __d, size_t __s)
diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/dr543.cc b/libstdc++-v3/testsuite/26_numerics/valarray/dr543.cc
new file mode 100644
index 00000000000..9afa93a4b83
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/valarray/dr543.cc
@@ -0,0 +1,40 @@
+// Copyright (C) 2006 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <valarray>
+#include <testsuite_hooks.h>
+
+// DR 543. valarray slice default constructor
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::valarray<int> v1(10);
+ std::valarray<int> v2 = v1[std::slice()];
+ VERIFY( v2.size() == 0 );
+
+ std::valarray<int> v3(10);
+ std::valarray<int> v4 = v3[std::gslice()];
+ VERIFY( v4.size() == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}