diff options
Diffstat (limited to 'include/unordered_map')
-rw-r--r-- | include/unordered_map | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/include/unordered_map b/include/unordered_map index 78fee4811fadf..0fa87d19ad035 100644 --- a/include/unordered_map +++ b/include/unordered_map @@ -351,6 +351,8 @@ template <class Key, class T, class Hash, class Pred, class Alloc> #include <functional> #include <stdexcept> +#include <__debug> + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif @@ -831,12 +833,14 @@ public: #if __cplusplus >= 201103L __table_ = __u.__table_; #else - __table_.clear(); - __table_.hash_function() = __u.__table_.hash_function(); - __table_.key_eq() = __u.__table_.key_eq(); - __table_.max_load_factor() = __u.__table_.max_load_factor(); - __table_.__copy_assign_alloc(__u.__table_); - insert(__u.begin(), __u.end()); + if (this != &__u) { + __table_.clear(); + __table_.hash_function() = __u.__table_.hash_function(); + __table_.key_eq() = __u.__table_.key_eq(); + __table_.max_load_factor() = __u.__table_.max_load_factor(); + __table_.__copy_assign_alloc(__u.__table_); + insert(__u.begin(), __u.end()); + } #endif return *this; } @@ -1567,12 +1571,14 @@ public: #if __cplusplus >= 201103L __table_ = __u.__table_; #else - __table_.clear(); - __table_.hash_function() = __u.__table_.hash_function(); - __table_.key_eq() = __u.__table_.key_eq(); - __table_.max_load_factor() = __u.__table_.max_load_factor(); - __table_.__copy_assign_alloc(__u.__table_); - insert(__u.begin(), __u.end()); + if (this != &__u) { + __table_.clear(); + __table_.hash_function() = __u.__table_.hash_function(); + __table_.key_eq() = __u.__table_.key_eq(); + __table_.max_load_factor() = __u.__table_.max_load_factor(); + __table_.__copy_assign_alloc(__u.__table_); + insert(__u.begin(), __u.end()); + } #endif return *this; } |