Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vector 'no operator "[]" matches these operands' error in Visual Studio watch

When stepping through the following sample code in Visual Studio 2012:

std::vector<int> test; test.resize(1); test[0] = 4; 

I can set a watch on test and inspect its 0th element. However, if I set a watch on test[0], I get the error 'no operator "[]" matches these operands':

enter image description here

How can I inspect the value of test[0] directly?

like image 419
1'' Avatar asked Jul 23 '13 00:07

1''


1 Answers

I found one solution which does not depend on the internals of the class. The expanded form of the operator call seems to work for me. In this case it's the following code:

v.operator[](0) 

I tested it in Visual C++ 2012.

like image 195
Max Avatar answered Sep 17 '22 17:09

Max