size_type max_size() const { return m_.cont_.max_size(); }
bool empty() const { return m_.cont_.empty(); }
void reserve(size_type s) { return m_.cont_.reserve(s); }
+ void shrink_to_fit() { m_.cont_.shrink_to_fit(); }
size_type capacity() const { return m_.cont_.capacity(); }
std::pair<iterator,bool> insert(const value_type& value) {
size_type max_size() const { return m_.cont_.max_size(); }
bool empty() const { return m_.cont_.empty(); }
void reserve(size_type s) { return m_.cont_.reserve(s); }
+ void shrink_to_fit() { m_.cont_.shrink_to_fit(); }
size_type capacity() const { return m_.cont_.capacity(); }
std::pair<iterator,bool> insert(const value_type& value) {
EXPECT_EQ(*m[5], 5);
EXPECT_EQ(*m[10], 10);
}
+
+TEST(SortedVectorTest, ShrinkTest) {
+ sorted_vector_set<int> s;
+ int i = 0;
+ // Hopefully your resize policy doubles when capacity is full, or this will
+ // hang forever :(
+ while (s.capacity() == s.size()) {
+ s.insert(i++);
+ }
+ s.shrink_to_fit();
+ // The standard does not actually enforce that this be true, but assume that
+ // vector::shrink_to_fit respects the caller.
+ EXPECT_EQ(s.capacity(), s.size());
+}