I'm doing an exercise and encounter a problem.
To solve this exercise, I have to write a template class MySet as a wrapper of STL::set.
In the following, there is code like
pair<MySet<int>::iterator, MySet<int>::iterator> p
where pair comes from the STL.
Now what should I do to support MySet<int>::iterator
?
I've tried typedef set<T>::iterator MySet<T>::iterator
and typedef T* iterator
but they all failed.
===============================EDIT================================
#include <iostream>
#include <set>
using namespace std;
template<class T, class Q = greater<T> >
class MySet
{
public:
using iterator = typename set<T, Q>::iterator;
typedef typename set<T, Q>::iterator iterator;
set<T, Q> tset;
void insert(T value)
{
tset.insert(value);
}
};
int main()
{
MySet<int> intset;
intset.insert(5);
intset.insert(10);
MySet<int>::iterator p;
}