<div dir="ltr">ping.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 28, 2016 at 7:52 PM, Eric Fiselier <span dir="ltr"><<a href="mailto:eric@efcs.ca" target="_blank">eric@efcs.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>@Hans While working on the std::tuple bug I found this bug in std::pair. Since we are already doing another RC I would like to merge this fix.</div><div><br></div><div>@Marshall Sound OK to you?</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>/Eric</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 28, 2016 at 7:43 PM, Eric Fiselier via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ericwf<br>
Date: Sun Aug 28 20:43:41 2016<br>
New Revision: 279955<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=279955&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=279955&view=rev</a><br>
Log:<br>
Fix pair::operator=(TupleLike&&).<br>
<br>
This assignment operator was previously broken since the SFINAE always resulted<br>
in substitution failure. This caused assignments to turn into<br>
copy construction + assignment.<br>
<br>
This patch was originally committed as r279953 but was reverted due to warnings<br>
in the test-suite. This new patch corrects those warnings.<br>
<br>
Added:<br>
libcxx/trunk/test/std/utilitie<wbr>s/utility/pairs/pairs.pair/<wbr>assign_tuple.pass.cpp<br>
Modified:<br>
libcxx/trunk/include/utility<br>
<br>
Modified: libcxx/trunk/include/utility<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=279955&r1=279954&r2=279955&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/libcxx/trunk/include/uti<wbr>lity?rev=279955&r1=279954&r2=<wbr>279955&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/include/utility (original)<br>
+++ libcxx/trunk/include/utility Sun Aug 28 20:43:41 2016<br>
@@ -515,7 +515,7 @@ struct _LIBCPP_TYPE_VIS_ONLY pair<br>
}<br>
<br>
template <class _Tuple, _EnableB<<br>
- _CheckTLC<_Tuple>::template __enable_assign()<br>
+ _CheckTLC<_Tuple>::template __enable_assign<_Tuple>()<br>
> = false><br>
_LIBCPP_INLINE_VISIBILITY<br>
pair& operator=(_Tuple&& __p) {<br>
<br>
Added: libcxx/trunk/test/std/utilitie<wbr>s/utility/pairs/pairs.pair/<wbr>assign_tuple.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_tuple.pass.cpp?rev=279955&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/libcxx/trunk/test/std/ut<wbr>ilities/utility/pairs/pairs.pa<wbr>ir/assign_tuple.pass.cpp?rev=<wbr>279955&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/test/std/utilitie<wbr>s/utility/pairs/pairs.pair/<wbr>assign_tuple.pass.cpp (added)<br>
+++ libcxx/trunk/test/std/utilitie<wbr>s/utility/pairs/pairs.pair/<wbr>assign_tuple.pass.cpp Sun Aug 28 20:43:41 2016<br>
@@ -0,0 +1,140 @@<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is dual licensed under the MIT and the University of Illinois Open<br>
+// Source Licenses. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+// UNSUPPORTED: c++98, c++03<br>
+<br>
+// <utility><br>
+<br>
+// template <class T1, class T2> struct pair<br>
+<br>
+// template<class U, class V> pair& operator=(tuple<U, V>&& p);<br>
+<br>
+#include <utility><br>
+#include <tuple><br>
+#include <array><br>
+#include <memory><br>
+#include <cassert><br>
+<br>
+// Clang warns about missing braces when initializing std::array.<br>
+#if defined(__clang__)<br>
+#pragma clang diagnostic ignored "-Wmissing-braces"<br>
+#endif<br>
+<br>
+struct CountingType {<br>
+ static int constructed;<br>
+ static int copy_constructed;<br>
+ static int move_constructed;<br>
+ static int assigned;<br>
+ static int copy_assigned;<br>
+ static int move_assigned;<br>
+ static void reset() {<br>
+ constructed = copy_constructed = move_constructed = 0;<br>
+ assigned = copy_assigned = move_assigned = 0;<br>
+ }<br>
+ CountingType() : value(0) { ++constructed; }<br>
+ CountingType(int v) : value(v) { ++constructed; }<br>
+ CountingType(CountingType const& o) : value(o.value) { ++constructed; ++copy_constructed; }<br>
+ CountingType(CountingType&& o) : value(o.value) { ++constructed; ++move_constructed; o.value = -1;}<br>
+<br>
+ CountingType& operator=(CountingType const& o) {<br>
+ ++assigned;<br>
+ ++copy_assigned;<br>
+ value = o.value;<br>
+ return *this;<br>
+ }<br>
+ CountingType& operator=(CountingType&& o) {<br>
+ ++assigned;<br>
+ ++move_assigned;<br>
+ value = o.value;<br>
+ o.value = -1;<br>
+ return *this;<br>
+ }<br>
+ int value;<br>
+};<br>
+int CountingType::constructed;<br>
+int CountingType::copy_constructed<wbr>;<br>
+int CountingType::move_constructed<wbr>;<br>
+int CountingType::assigned;<br>
+int CountingType::copy_assigned;<br>
+int CountingType::move_assigned;<br>
+<br>
+int main()<br>
+{<br>
+ using C = CountingType;<br>
+ {<br>
+ using P = std::pair<int, C>;<br>
+ using T = std::tuple<int, C>;<br>
+ T t(42, C{42});<br>
+ P p(101, C{101});<br>
+ C::reset();<br>
+ p = t;<br>
+ assert(C::constructed == 0);<br>
+ assert(C::assigned == 1);<br>
+ assert(C::copy_assigned == 1);<br>
+ assert(C::move_assigned == 0);<br>
+ assert(p.first == 42);<br>
+ assert(p.second.value == 42);<br>
+ }<br>
+ {<br>
+ using P = std::pair<int, C>;<br>
+ using T = std::tuple<int, C>;<br>
+ T t(42, -42);<br>
+ P p(101, 101);<br>
+ C::reset();<br>
+ p = std::move(t);<br>
+ assert(C::constructed == 0);<br>
+ assert(C::assigned == 1);<br>
+ assert(C::copy_assigned == 0);<br>
+ assert(C::move_assigned == 1);<br>
+ assert(p.first == 42);<br>
+ assert(p.second.value == -42);<br>
+ }<br>
+ {<br>
+ using P = std::pair<C, C>;<br>
+ using T = std::array<C, 2>;<br>
+ T t = {42, -42};<br>
+ P p{101, 101};<br>
+ C::reset();<br>
+ p = t;<br>
+ assert(C::constructed == 0);<br>
+ assert(C::assigned == 2);<br>
+ assert(C::copy_assigned == 2);<br>
+ assert(C::move_assigned == 0);<br>
+ assert(p.first.value == 42);<br>
+ assert(p.second.value == -42);<br>
+ }<br>
+ {<br>
+ using P = std::pair<C, C>;<br>
+ using T = std::array<C, 2>;<br>
+ T t = {42, -42};<br>
+ P p{101, 101};<br>
+ C::reset();<br>
+ p = t;<br>
+ assert(C::constructed == 0);<br>
+ assert(C::assigned == 2);<br>
+ assert(C::copy_assigned == 2);<br>
+ assert(C::move_assigned == 0);<br>
+ assert(p.first.value == 42);<br>
+ assert(p.second.value == -42);<br>
+ }<br>
+ {<br>
+ using P = std::pair<C, C>;<br>
+ using T = std::array<C, 2>;<br>
+ T t = {42, -42};<br>
+ P p{101, 101};<br>
+ C::reset();<br>
+ p = std::move(t);<br>
+ assert(C::constructed == 0);<br>
+ assert(C::assigned == 2);<br>
+ assert(C::copy_assigned == 0);<br>
+ assert(C::move_assigned == 2);<br>
+ assert(p.first.value == 42);<br>
+ assert(p.second.value == -42);<br>
+ }<br>
+}<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>