summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4>2014-04-11 19:23:49 +0000
committerglisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4>2014-04-11 19:23:49 +0000
commit3b4923ce8505182ce3054235f3f8b2bc3172b1c5 (patch)
tree0118e4dad175f402207a2fd5dfbb1b0f0baca2f9
parentceaf91adc43f95ee40d706cabdad9bc4a1ca25fa (diff)
downloadgcc-3b4923ce8505182ce3054235f3f8b2bc3172b1c5.tar.gz
2014-04-11 Marc Glisse <marc.glisse@inria.fr>
PR libstdc++/59434 * include/bits/stl_iterator.h (move_iterator::reference, move_iterator::operator*): Implement LWG 2106. * testsuite/24_iterators/move_iterator/dr2106.cc: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@209323 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/stl_iterator.h9
-rw-r--r--libstdc++-v3/testsuite/24_iterators/move_iterator/dr2106.cc33
3 files changed, 47 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 1af136e639b..1d0e19a4e51 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,12 @@
2014-04-11 Marc Glisse <marc.glisse@inria.fr>
+ PR libstdc++/59434
+ * include/bits/stl_iterator.h (move_iterator::reference,
+ move_iterator::operator*): Implement LWG 2106.
+ * testsuite/24_iterators/move_iterator/dr2106.cc: New file.
+
+2014-04-11 Marc Glisse <marc.glisse@inria.fr>
+
* include/std/complex (__complex_exp, pow): Specify the template
parameter in calls to std::polar, for expression templates.
diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index 1d2a52419d9..16f992c7490 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -965,6 +965,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Iterator _M_current;
typedef iterator_traits<_Iterator> __traits_type;
+ typedef typename __traits_type::reference __base_ref;
public:
typedef _Iterator iterator_type;
@@ -973,7 +974,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef typename __traits_type::difference_type difference_type;
// NB: DR 680.
typedef _Iterator pointer;
- typedef value_type&& reference;
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2106. move_iterator wrapping iterators returning prvalues
+ typedef typename conditional<is_reference<__base_ref>::value,
+ typename remove_reference<__base_ref>::type&&,
+ __base_ref>::type reference;
move_iterator()
: _M_current() { }
@@ -992,7 +997,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
reference
operator*() const
- { return std::move(*_M_current); }
+ { return static_cast<reference>(*_M_current); }
pointer
operator->() const
diff --git a/libstdc++-v3/testsuite/24_iterators/move_iterator/dr2106.cc b/libstdc++-v3/testsuite/24_iterators/move_iterator/dr2106.cc
new file mode 100644
index 00000000000..fc155620288
--- /dev/null
+++ b/libstdc++-v3/testsuite/24_iterators/move_iterator/dr2106.cc
@@ -0,0 +1,33 @@
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <iterator>
+#include <type_traits>
+#include <vector>
+
+typedef std::vector<bool> Vec;
+typedef Vec::reference Ref;
+typedef Vec::const_reference CRef;
+typedef Vec::iterator It;
+typedef Vec::const_iterator CIt;
+typedef std::move_iterator<It> MIt;
+typedef std::move_iterator<CIt> MCIt;
+static_assert(std::is_same<MIt::reference, Ref>::value,"");
+static_assert(std::is_same<MCIt::reference, CRef>::value,"");