Re: typename iterator_traits::pointer
Ioannis Vranos wrote:
Pete Becker wrote:
On 2008-01-24 08:34:15 -0500, "Victor Bazarov"
<v.Abazarov@comAcast.net> said:
Ioannis Vranos wrote:
Let's assume vector<int> as an example and we want to get a
pointer to the first element of the sequence using operator->():
#include <vector>
#include <iostream>
#include <iterator>
int main()
{
using namespace std;
vector<int> vec(10);
iterator_traits<vector<int>::iterator>::pointer p= ???
}
There is no syntax in C++ to do what you seem to want/need.
Sure there is:
p = vec.begin().operator->();
A more natural way to write it, without the artificial requirment
of using operator->, would be:
p = &*vec.begin();
which is the usual technique for getting the address of an element,
given an iterator.
And what is the use/need of Iter.operator->()?
Nothing much for vector<int>, but might be useful for accessing the
members of vector<some_struct>.
Bo Persson