[cfe-commits] [libcxx] r134248 - in /libcxx/trunk: include/map include/memory include/set include/unordered_map include/unordered_set include/utility test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp

Howard Hinnant hhinnant at apple.com
Fri Jul 1 12:24:36 PDT 2011


Author: hhinnant
Date: Fri Jul  1 14:24:36 2011
New Revision: 134248

URL: http://llvm.org/viewvc/llvm-project?rev=134248&view=rev
Log:
Correct for new rules regarding implicitly deleted special members. http://llvm.org/bugs/show_bug.cgi?id=10191

Modified:
    libcxx/trunk/include/map
    libcxx/trunk/include/memory
    libcxx/trunk/include/set
    libcxx/trunk/include/unordered_map
    libcxx/trunk/include/unordered_set
    libcxx/trunk/include/utility
    libcxx/trunk/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
    libcxx/trunk/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp

Modified: libcxx/trunk/include/map
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/map?rev=134248&r1=134247&r2=134248&view=diff
==============================================================================
--- libcxx/trunk/include/map (original)
+++ libcxx/trunk/include/map Fri Jul  1 14:24:36 2011
@@ -755,6 +755,13 @@
             insert(__m.begin(), __m.end());
         }
 
+    _LIBCPP_INLINE_VISIBILITY
+    map& operator=(const map& __m)
+        {
+            __tree_ = __m.__tree_;
+            return *this;
+        }
+
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
     _LIBCPP_INLINE_VISIBILITY
@@ -1497,6 +1504,13 @@
             insert(__m.begin(), __m.end());
         }
 
+    _LIBCPP_INLINE_VISIBILITY
+    multimap& operator=(const multimap& __m)
+        {
+            __tree_ = __m.__tree_;
+            return *this;
+        }
+
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
     _LIBCPP_INLINE_VISIBILITY

Modified: libcxx/trunk/include/memory
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=134248&r1=134247&r2=134248&view=diff
==============================================================================
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Fri Jul  1 14:24:36 2011
@@ -1889,13 +1889,48 @@
     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
         : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {}
 
+#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
+                   is_nothrow_copy_constructible<_T2>::value)
+        : __first_(__p.first()),
+          __second_(__p.second()) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
+                   is_nothrow_copy_assignable<_T2>::value)
+        {
+            __first_ = __p.first();
+            __second_ = __p.second();
+            return *this;
+        }
+
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
                    is_nothrow_move_constructible<_T2>::value)
-        : __first_(_VSTD::forward<_T1>(__p.first())), __second_(_VSTD::forward<_T2>(__p.second())) {}
+        : __first_(_VSTD::forward<_T1>(__p.first())),
+          __second_(_VSTD::forward<_T2>(__p.second())) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
+        _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
+                   is_nothrow_move_assignable<_T2>::value)
+        {
+            __first_ = _VSTD::forward<_T1>(__p.first());
+            __second_ = _VSTD::forward<_T2>(__p.second());
+            return *this;
+        }
+
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
+#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return __first_;}
     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;}
 
@@ -1936,13 +1971,46 @@
     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
         : _T1(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {}
 
+#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
+                   is_nothrow_copy_constructible<_T2>::value)
+        : _T1(__p.first()), __second_(__p.second()) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
+                   is_nothrow_copy_assignable<_T2>::value)
+        {
+            _T1::operator=(__p.first());
+            __second_ = __p.second();
+            return *this;
+        }
+
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
                    is_nothrow_move_constructible<_T2>::value)
         : _T1(_VSTD::move(__p.first())), __second_(_VSTD::forward<_T2>(__p.second())) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
+        _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
+                   is_nothrow_move_assignable<_T2>::value)
+        {
+            _T1::operator=(_VSTD::move(__p.first()));
+            __second_ = _VSTD::forward<_T2>(__p.second());
+            return *this;
+        }
+
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
+#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return *this;}
     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;}
 
@@ -1984,11 +2052,46 @@
                    is_nothrow_move_constructible<_T2>::value)
         : _T2(_VSTD::forward<_T2_param>(__t2)), __first_(_VSTD::forward<_T1_param>(__t1)) {}
 
+#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
+                   is_nothrow_copy_constructible<_T2>::value)
+        : _T2(__p.second()), __first_(__p.first()) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
+                   is_nothrow_copy_assignable<_T2>::value)
+        {
+            _T2::operator=(__p.second());
+            __first_ = __p.first();
+            return *this;
+        }
+
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
     __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
+        _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
+                   is_nothrow_move_constructible<_T2>::value)
         : _T2(_VSTD::forward<_T2>(__p.second())), __first_(_VSTD::move(__p.first())) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
+        _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
+                   is_nothrow_move_assignable<_T2>::value)
+        {
+            _T2::operator=(_VSTD::forward<_T2>(__p.second()));
+            __first_ = _VSTD::move(__p.first());
+            return *this;
+        }
+
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
+#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return __first_;}
     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;}
 
@@ -2027,13 +2130,46 @@
     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
         : _T1(_VSTD::forward<_T1_param>(__t1)), _T2(_VSTD::forward<_T2_param>(__t2)) {}
 
+#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
+                   is_nothrow_copy_constructible<_T2>::value)
+        : _T1(__p.first()), _T2(__p.second()) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
+                   is_nothrow_copy_assignable<_T2>::value)
+        {
+            _T1::operator=(__p.first());
+            _T2::operator=(__p.second());
+            return *this;
+        }
+
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
                    is_nothrow_move_constructible<_T2>::value)
         : _T1(_VSTD::move(__p.first())), _T2(_VSTD::move(__p.second())) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
+        _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
+                   is_nothrow_move_assignable<_T2>::value)
+        {
+            _T1::operator=(_VSTD::move(__p.first()));
+            _T2::operator=(_VSTD::move(__p.second()));
+            return *this;
+        }
+
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
+#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return *this;}
     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;}
 
@@ -2070,13 +2206,42 @@
     _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2)
         : base(_VSTD::forward<_T1_param>(__t1), _VSTD::forward<_T2_param>(__t2)) {}
 
+#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
+    _LIBCPP_INLINE_VISIBILITY
+    __compressed_pair(const __compressed_pair& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
+                   is_nothrow_copy_constructible<_T2>::value)
+        : base(__p) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __compressed_pair& operator=(const __compressed_pair& __p)
+        _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
+                   is_nothrow_copy_assignable<_T2>::value)
+        {
+            base::operator=(__p);
+            return *this;
+        }
+
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
     __compressed_pair(__compressed_pair&& __p)
         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
                    is_nothrow_move_constructible<_T2>::value)
         : base(_VSTD::move(__p)) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __compressed_pair& operator=(__compressed_pair&& __p)
+        _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
+                   is_nothrow_move_assignable<_T2>::value)
+        {
+            base::operator=(_VSTD::move(__p));
+            return *this;
+        }
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
+#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return base::first();}
     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return base::first();}
 

Modified: libcxx/trunk/include/set
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/set?rev=134248&r1=134247&r2=134248&view=diff
==============================================================================
--- libcxx/trunk/include/set (original)
+++ libcxx/trunk/include/set Fri Jul  1 14:24:36 2011
@@ -408,6 +408,13 @@
             insert(__s.begin(), __s.end());
         }
 
+    _LIBCPP_INLINE_VISIBILITY
+    set& operator=(const set& __s)
+        {
+            __tree_ = __s.__tree_;
+            return *this;
+        }
+
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     _LIBCPP_INLINE_VISIBILITY
     set(set&& __s)
@@ -738,6 +745,13 @@
             insert(__s.begin(), __s.end());
         }
 
+    _LIBCPP_INLINE_VISIBILITY
+    multiset& operator=(const multiset& __s)
+        {
+            __tree_ = __s.__tree_;
+            return *this;
+        }
+
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     _LIBCPP_INLINE_VISIBILITY
     multiset(multiset&& __s)

Modified: libcxx/trunk/include/unordered_map
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_map?rev=134248&r1=134247&r2=134248&view=diff
==============================================================================
--- libcxx/trunk/include/unordered_map (original)
+++ libcxx/trunk/include/unordered_map Fri Jul  1 14:24:36 2011
@@ -691,7 +691,12 @@
                   const hasher& __hf, const key_equal& __eql,
                   const allocator_type& __a);
     // ~unordered_map() = default;
-    // unordered_map& operator=(const unordered_map& __u) = default;
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_map& operator=(const unordered_map& __u)
+    {
+        __table_ = __u.__table_;
+        return *this;
+    }
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     unordered_map& operator=(unordered_map&& __u)
         _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
@@ -1295,7 +1300,12 @@
                        const hasher& __hf, const key_equal& __eql,
                        const allocator_type& __a);
     // ~unordered_multimap() = default;
-    // unordered_multimap& operator=(const unordered_multimap& __u) = default;
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_multimap& operator=(const unordered_multimap& __u)
+    {
+        __table_ = __u.__table_;
+        return *this;
+    }
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     unordered_multimap& operator=(unordered_multimap&& __u)
         _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);

Modified: libcxx/trunk/include/unordered_set
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_set?rev=134248&r1=134247&r2=134248&view=diff
==============================================================================
--- libcxx/trunk/include/unordered_set (original)
+++ libcxx/trunk/include/unordered_set Fri Jul  1 14:24:36 2011
@@ -373,7 +373,12 @@
                   const hasher& __hf, const key_equal& __eql,
                   const allocator_type& __a);
     // ~unordered_set() = default;
-    // unordered_set& operator=(const unordered_set& __u) = default;
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_set& operator=(const unordered_set& __u)
+    {
+        __table_ = __u.__table_;
+        return *this;
+    }
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     unordered_set& operator=(unordered_set&& __u)
         _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
@@ -766,7 +771,12 @@
                        const hasher& __hf, const key_equal& __eql,
                        const allocator_type& __a);
     // ~unordered_multiset() = default;
-    // unordered_multiset& operator=(const unordered_multiset& __u) = default;
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_multiset& operator=(const unordered_multiset& __u)
+    {
+        __table_ = __u.__table_;
+        return *this;
+    }
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     unordered_multiset& operator=(unordered_multiset&& __u)
         _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);

Modified: libcxx/trunk/include/utility
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=134248&r1=134247&r2=134248&view=diff
==============================================================================
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Fri Jul  1 14:24:36 2011
@@ -232,7 +232,18 @@
             : first(__p.first), second(__p.second) {}
 
     _LIBCPP_INLINE_VISIBILITY
+    pair(const pair& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
+                   is_nothrow_copy_constructible<second_type>::value)
+        : first(__p.first),
+          second(__p.second)
+    {
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
     pair& operator=(const pair& __p)
+        _NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value &&
+                   is_nothrow_copy_assignable<second_type>::value)
     {
         first = __p.first;
         second = __p.second;
@@ -259,6 +270,14 @@
               second(_VSTD::forward<_U2>(__p.second)) {}
 
     _LIBCPP_INLINE_VISIBILITY
+    pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible<first_type>::value &&
+                                is_nothrow_move_constructible<second_type>::value)
+        : first(_VSTD::forward<first_type>(__p.first)),
+          second(_VSTD::forward<second_type>(__p.second))
+    {
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
     pair&
     operator=(pair&& __p) _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
                                      is_nothrow_move_assignable<second_type>::value)

Modified: libcxx/trunk/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp?rev=134248&r1=134247&r2=134248&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp Fri Jul  1 14:24:36 2011
@@ -107,7 +107,7 @@
     assert(new_called == 1);
     assert(f.target<A>());
     assert(f.target<int(*)(int)>() == 0);
-    std::function<int(int)> f2 = _STD::move(f);
+    std::function<int(int)> f2 = std::move(f);
     assert(A::count == 1);
     assert(new_called == 1);
     assert(f2.target<A>());

Modified: libcxx/trunk/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp?rev=134248&r1=134247&r2=134248&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp Fri Jul  1 14:24:36 2011
@@ -111,7 +111,7 @@
     assert(f.target<A>());
     assert(f.target<int(*)(int)>() == 0);
     std::function<int(int)> f2;
-    f2 = _STD::move(f);
+    f2 = std::move(f);
     assert(A::count == 1);
     assert(new_called == 1);
     assert(f2.target<A>());





More information about the cfe-commits mailing list