* [patch] Make std::reference_wrapper trivially copyable.
@ 2014-11-04 2:53 Jonathan Wakely
2014-11-04 4:26 ` Jonathan Wakely
0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Wakely @ 2014-11-04 2:53 UTC (permalink / raw)
To: libstdc++, gcc-patches; +Cc: Agustín K-ballo Bergé
[-- Attachment #1: Type: text/x-patch, Size: 127 bytes --]
This might be required for C++17, and is beneficial anyway, so let's
change it now.
Tested x86_64-linux, committed to trunk.
[-- Attachment #2: patch-4.txt --]
[-- Type: text/plain, Size: 3580 bytes --]
commit 3b1cfc115060eb85f2a43c4bef80d25c4aefaa95
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Nov 4 01:51:48 2014 +0000
Make reference_wrapper trivially copyable.
* include/std/functional (reference_wrapper): Define copy constructor
and copy assignment as defaulted.
* testsuite/20_util/bind/ref_neg.cc: Adjust dg-error.
* testsuite/20_util/reference_wrapper/requirements.cc: New.
diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional
index f8e9b54..25ec1b3 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -410,16 +410,10 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
reference_wrapper(_Tp&&) = delete;
- reference_wrapper(const reference_wrapper<_Tp>& __inref) noexcept
- : _M_data(__inref._M_data)
- { }
+ reference_wrapper(const reference_wrapper&) = default;
reference_wrapper&
- operator=(const reference_wrapper<_Tp>& __inref) noexcept
- {
- _M_data = __inref._M_data;
- return *this;
- }
+ operator=(const reference_wrapper&) = default;
operator _Tp&() const noexcept
{ return this->get(); }
diff --git a/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc b/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
index 1063dd3..4e627cf 100644
--- a/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
@@ -30,10 +30,10 @@ void test01()
{
const int dummy = 0;
std::bind(&inc, _1)(0); // { dg-error "no match" }
- // { dg-error "rvalue|const" "" { target *-*-* } 1213 }
- // { dg-error "rvalue|const" "" { target *-*-* } 1227 }
- // { dg-error "rvalue|const" "" { target *-*-* } 1241 }
- // { dg-error "rvalue|const" "" { target *-*-* } 1255 }
+ // { dg-error "rvalue|const" "" { target *-*-* } 1207 }
+ // { dg-error "rvalue|const" "" { target *-*-* } 1221 }
+ // { dg-error "rvalue|const" "" { target *-*-* } 1235 }
+ // { dg-error "rvalue|const" "" { target *-*-* } 1249 }
std::bind(&inc, std::ref(dummy))(); // { dg-error "no match" }
}
diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/requirements.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/requirements.cc
new file mode 100644
index 0000000..c4d784c
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/requirements.cc
@@ -0,0 +1,32 @@
+// 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/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <functional>
+
+struct NonTrivial
+{
+ ~NonTrivial() { }
+};
+
+using R = std::reference_wrapper<NonTrivial>;
+
+static_assert(std::is_copy_constructible<R>::value, "copy constructible");
+static_assert(std::is_copy_assignable<R>::value, "copy assignable");
+static_assert(std::is_trivially_copyable<R>::value, "trivially copyable");
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch] Make std::reference_wrapper trivially copyable.
2014-11-04 2:53 [patch] Make std::reference_wrapper trivially copyable Jonathan Wakely
@ 2014-11-04 4:26 ` Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2014-11-04 4:26 UTC (permalink / raw)
To: libstdc++, gcc-patches; +Cc: Agustín K-ballo Bergé
Messed up the content-types here too, the body was meant to be:
On 04/11/14 02:53 +0000, Jonathan Wakely wrote:
>This might be required for C++17, and is beneficial anyway, so let's
>change it now.
>
>Tested x86_64-linux, committed to trunk.
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-04 4:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-04 2:53 [patch] Make std::reference_wrapper trivially copyable Jonathan Wakely
2014-11-04 4:26 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).