0

Update

It seems we can't use the *iter to get the value of the element in the iterator.

So is there a easy way to get the value of the iter ?

I don't want to type the iter->xxx._xxx->_xxx everytime.

I tried to use AHK to remap the string, is there a better way ?


I use *iterator in the immediately window in Visual Studio 2013. The iterator is defined as std::vector<std::string>::iterator iter = a.begin()

And I want to check the value of the string which the iterator point to.

But I get the error

There is no operator * matches the operand

[I update the pic and add some comment

Why's that ? Or how can I get the value of the iterator in a easy way?

lizhe
  • 49
  • 2
  • 7

2 Answers2

0

There's essentially no solution, it's one of the areas in which Visual Studio has been stuck in the previous century. There's apparently too much fragile technology, and trying to fix one bit of Visual Studio (edit&continue) breaks another (debugger visualization)

Community
  • 1
  • 1
MSalters
  • 173,980
  • 10
  • 155
  • 350
0

The * operator is overloaded for iterators in order to give you access to their underlying value, and keep the same semantics as pointers. Pointers can be considered, in some context, as iterators, for example when iterating over a C-style array. That's why you can use C- style arrays in STL algorithms.

The immediate window in visual studio seems to not understand that the * operator is overloaded for your iterator type. That's why you get this error.

arainone
  • 1,928
  • 17
  • 28
  • So it's there a better way to get the element value in the iterator? – lizhe Jan 18 '16 at 11:02
  • There is a way to define your own viewers for **watches** and **debug value popups** [in this thread] (http://stackoverflow.com/a/111634/4515566) but I'm not aware that it's working for the **Immediate** window but I guess that's not a problem if you just want to see the value, right? – arainone Jan 18 '16 at 12:01