向量'无操作符'[]在Visual Studio中匹配这些操作数的错误 [英] Vector 'no operator "[]" matches these operands' error in Visual Studio watch

查看:158
本文介绍了向量'无操作符'[]在Visual Studio中匹配这些操作数的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio 2012中逐步执行以下示例代码时:

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

我可以在测试中设置手表,并检查其第0个元素。但是,如果我在test [0]上设置了一个watch,我得到错误no operator[]匹配这些操作数:





如何检查test [0]直接?

解决方案

我发现一个解决方案不依赖于类的内部。扩展形式的操作符调用似乎对我有用。在这种情况下,它是以下代码:

  v.operator [](0)



我在Visual C ++ 2012中测试了它。


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':

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

解决方案

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.

这篇关于向量'无操作符'[]在Visual Studio中匹配这些操作数的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆