I need a vector which stores elements in sorted order (I need constant-time random access too, so not std::set). I am trying to implement that by privately inheriting std::vector.
template <typename T, typename Tcomp = less<T> >
class SortedVector : private vector<T> {
Tcomp _comparator;
public:
using vector<T>::operator[];
using vector<T>::operator==;
using vector<T>::size;
I have a couple of questions:
- Is it a bad idea to inherit
std::vectorprivately? - I get the following error:
SortedVector.h:26:30: error: no members matching ‘std::vector<std::basic_string<char> >::operator==’ in ‘class std::vector<std::basic_string<char> >’
Any advice?
Aucun commentaire:
Enregistrer un commentaire