Kaydet (Commit) 96f07eef authored tarafından Michael Stahl's avatar Michael Stahl

sorted_vector should not inherit public std::vector

Clearly we don't want to expose std::vector<Value>::insert here, and
neither e.g. push_back.

Change-Id: I89917a23d6d9f36f56474cdc361ba4d513516122
üst 81181891
...@@ -34,7 +34,9 @@ public: ...@@ -34,7 +34,9 @@ public:
@tpl Compare comparison method @tpl Compare comparison method
*/ */
template <class Value, class Compare = std::less<Value> > template <class Value, class Compare = std::less<Value> >
class sorted_vector : public std::vector<Value>, private sorted_vector_compare<Value, Compare> class sorted_vector
: private std::vector<Value>
, private sorted_vector_compare<Value, Compare>
{ {
public: public:
typedef typename std::vector<Value>::iterator iterator; typedef typename std::vector<Value>::iterator iterator;
...@@ -45,8 +47,10 @@ public: ...@@ -45,8 +47,10 @@ public:
using std::vector<Value>::begin; using std::vector<Value>::begin;
using std::vector<Value>::end; using std::vector<Value>::end;
using std::vector<Value>::clear; using std::vector<Value>::clear;
using std::vector<Value>::insert;
using std::vector<Value>::erase; using std::vector<Value>::erase;
using std::vector<Value>::empty;
using std::vector<Value>::size;
using std::vector<Value>::operator[];
// MODIFIERS // MODIFIERS
...@@ -56,7 +60,7 @@ public: ...@@ -56,7 +60,7 @@ public:
iterator it = std::lower_bound( begin(), end(), x, me ); iterator it = std::lower_bound( begin(), end(), x, me );
if( it == end() || less_than(x, *it) ) if( it == end() || less_than(x, *it) )
{ {
it = insert( it, x ); it = std::vector<Value>::insert( it, x );
return std::make_pair( it, true ); return std::make_pair( it, true );
} }
return std::make_pair( it, false ); return std::make_pair( it, false );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment