Make reference_wrapper trivially copyable.
authorJonathan Wakely <jwakely@redhat.com>
Tue, 4 Nov 2014 02:49:33 +0000 (02:49 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 4 Nov 2014 02:49:33 +0000 (02:49 +0000)
* 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.

From-SVN: r217067

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/functional
libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
libstdc++-v3/testsuite/20_util/reference_wrapper/requirements.cc [new file with mode: 0644]

index 19a86a08cf5e9ac32599722ae4942af21be8866f..4f2c9b5ab65fd06f7fd1d5ddef64df63aeb64842 100644 (file)
        * include/bits/regex.tcc (regex_traits::lookup_classname): Use
        ctype_base::blank.
 
+       * 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.
+
 2014-11-03  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * include/parallel/algo.h: Do not use default arguments in function
index f8e9b54fd9162e0bf5a61909ae9e242a3d0cd74f..25ec1b351b8b59147f1a3d242b6311b8970ab894 100644 (file)
@@ -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(); }
index 1063dd35d7e0752124aae0dbae9afcf417a7cb04..4e627cfaf487d5a550e38abb66e332c4d8fb4518 100644 (file)
@@ -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 (file)
index 0000000..c4d784c
--- /dev/null
@@ -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");