From: Eric Fiselier Date: Fri, 22 Apr 2016 00:49:12 +0000 (+0000) Subject: Fix LWG issue #2106: move_iterators returning prvalues X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=906c50859b0d75725850b770f87b71b9d541ecd4;p=platform%2Fupstream%2Fllvm.git Fix LWG issue #2106: move_iterators returning prvalues llvm-svn: 267091 --- diff --git a/libcxx/include/iterator b/libcxx/include/iterator index e6f4723..0e60aa9 100644 --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -951,7 +951,12 @@ public: typedef typename iterator_traits::difference_type difference_type; typedef iterator_type pointer; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - typedef value_type&& reference; + typedef typename iterator_traits::reference __reference; + typedef typename conditional< + is_reference<__reference>::value, + typename remove_reference<__reference>::type&&, + __reference + >::type reference; #else typedef typename iterator_traits::reference reference; #endif diff --git a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp index 1a3081f..a6d4d61 100644 --- a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp @@ -26,8 +26,18 @@ #include #include +#include "test_macros.h" #include "test_iterators.h" +template +struct DummyIt { + typedef std::forward_iterator_tag iterator_category; + typedef ValueType value_type; + typedef std::ptrdiff_t difference_type; + typedef ValueType* pointer; + typedef Reference reference; +}; + template void test() @@ -38,7 +48,7 @@ test() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 static_assert((std::is_same::value), ""); #else static_assert((std::is_same::value), ""); @@ -53,4 +63,33 @@ int main() test >(); test >(); test(); +#if TEST_STD_VER >= 11 + { + typedef DummyIt T; + typedef std::move_iterator It; + static_assert(std::is_same::value, ""); + } + { + typedef DummyIt > T; + typedef std::move_iterator It; + static_assert(std::is_same >::value, ""); + } + { + // Check that move_iterator uses whatever reference type it's given + // when it's not a reference. + typedef DummyIt T; + typedef std::move_iterator It; + static_assert(std::is_same::value, ""); + } + { + typedef DummyIt T; + typedef std::move_iterator It; + static_assert(std::is_same::value, ""); + } + { + typedef DummyIt T; + typedef std::move_iterator It; + static_assert(std::is_same::value, ""); + } +#endif } diff --git a/libcxx/www/cxx1z_status.html b/libcxx/www/cxx1z_status.html index 81d13e4..23824e4 100644 --- a/libcxx/www/cxx1z_status.html +++ b/libcxx/www/cxx1z_status.html @@ -114,7 +114,7 @@ 2404mismatch()'s complexity needs to be updatedUrbanaComplete 2408SFINAE-friendly common_type / iterator_traits is missing in C++14Urbanacommon_type is waiting on LWG#2465 - 2106move_iterator wrapping iterators returning prvaluesUrbana + 2106move_iterator wrapping iterators returning prvaluesUrbanaComplete 2129User specializations of std::initializer_listUrbanaComplete 2212tuple_size for const pair request headerUrbanaComplete 2217operator==(sub_match, string) slices on embedded '\0'sUrbanaComplete