B
Bobo
Hello, all.
I have just wrote the following little class, and I'd like you to give
me your opinion about it. I compiles with VC6 but I'm not sure if it
is totally right.
I'm trying to explain the problem I try to solve: I had a class with a
private vector<T> member variable, and some public functions that use
iterators to the vector (with the apropiate public typedef for the
iterator type). But now I need to change the vector to a map. That's
easy. But the iterator iterates now with a std:air<I,T> type. And of
course I want to maintain the public interface.
template <class M>
class iterator_second : public M::iterator
{
public:
typedef typename M::iterator iterator_base;
typedef typename M::referent_type reference_type;
typedef reference_type *pointer_type;
iterator_second()
{}
iterator_second(iterator_base &it)
:iterator_base(it)
{}
reference_type &operator *()
{
return iterator_base:perator*().second;
}
pointer_type &operator ->()
{
return &iterator_base:perator->()->second;
}
};
// iterator_second<std::map<I,T> > iterates through the T values of
the map.
TIA.
Bobo.
I have just wrote the following little class, and I'd like you to give
me your opinion about it. I compiles with VC6 but I'm not sure if it
is totally right.
I'm trying to explain the problem I try to solve: I had a class with a
private vector<T> member variable, and some public functions that use
iterators to the vector (with the apropiate public typedef for the
iterator type). But now I need to change the vector to a map. That's
easy. But the iterator iterates now with a std:air<I,T> type. And of
course I want to maintain the public interface.
template <class M>
class iterator_second : public M::iterator
{
public:
typedef typename M::iterator iterator_base;
typedef typename M::referent_type reference_type;
typedef reference_type *pointer_type;
iterator_second()
{}
iterator_second(iterator_base &it)
:iterator_base(it)
{}
reference_type &operator *()
{
return iterator_base:perator*().second;
}
pointer_type &operator ->()
{
return &iterator_base:perator->()->second;
}
};
// iterator_second<std::map<I,T> > iterates through the T values of
the map.
TIA.
Bobo.