Skip to content

Commit

Permalink
add assign operation of initializer_list
Browse files Browse the repository at this point in the history
  • Loading branch information
zsmj committed Apr 11, 2019
1 parent 0b3989e commit 10fefb8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Associative containers/Set/stl_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ class set {
t = rhs.t;
return *this;
}
set& operator=(std::initializer_list<value_type> ils) {
clear();
insert(ils.begin(), ils.end());
return *this;
}

public: // move operation
set(set&& rhs) noexcept : t(std::move(rhs.t)) {}
Expand All @@ -95,7 +100,7 @@ class set {
const_reverse_iterator crend() const noexcept { return t.crend(); }

public: // swap
void swap(set<Key, Compare, Alloc>& rhs) noexcept { t.swap(rhs.t); }
void swap(set& rhs) noexcept { t.swap(rhs.t); }

public: // insert
pair<iterator, bool> insert(const value_type& val) {
Expand Down

0 comments on commit 10fefb8

Please sign in to comment.