#include <cstddef>
#include <cstring>
#include <cstdlib>
+#include <initializer_list>
#include <iterator>
#include <utility>
insert(*I);
}
+ void insert(std::initializer_list<PtrType> IL) {
+ insert(IL.begin(), IL.end());
+ }
+
inline iterator begin() const {
return iterator(CurArray, EndPointer());
}
this->insert(I, E);
}
+ SmallPtrSet(std::initializer_list<PtrType> IL)
+ : BaseT(SmallStorage, SmallSizePowTwo) {
+ this->insert(IL.begin(), IL.end());
+ }
+
SmallPtrSet<PtrType, SmallSize> &
operator=(const SmallPtrSet<PtrType, SmallSize> &RHS) {
if (&RHS != this)
return *this;
}
+ SmallPtrSet<PtrType, SmallSize> &
+ operator=(std::initializer_list<PtrType> IL) {
+ this->clear();
+ this->insert(IL.begin(), IL.end());
+ return *this;
+ }
+
/// swap - Swaps the elements of two sets.
void swap(SmallPtrSet<PtrType, SmallSize> &RHS) {
SmallPtrSetImplBase::swap(RHS);
for (int i = 0; i < 8; ++i)
buf[i] = 0;
- SmallPtrSet<int *, 4> s1;
- s1.insert(&buf[0]);
- s1.insert(&buf[1]);
-
+ SmallPtrSet<int *, 4> s1 = {&buf[0], &buf[1]};
SmallPtrSet<int *, 4> s2;
(s2 = s1).insert(&buf[2]);
EXPECT_TRUE(s1.count(&buf[i]));
else
EXPECT_FALSE(s1.count(&buf[i]));
+
+ // Assign and insert with initializer lists, and ones that contain both
+ // duplicates and out-of-order elements.
+ (s2 = {&buf[6], &buf[7], &buf[6]}).insert({&buf[5], &buf[4]});
+ for (int i = 0; i < 8; ++i)
+ if (i < 4)
+ EXPECT_FALSE(s2.count(&buf[i]));
+ else
+ EXPECT_TRUE(s2.count(&buf[i]));
}
TEST(SmallPtrSetTest, GrowthTest) {