【发布时间】:2020-11-22 06:47:15
【问题描述】:
如何在 Visual Studio 2019(企业版或社区版)中设置使用重载的 operator[] 进行评估的条件断点?我附上了一个最小的非工作示例。
#include <memory>
struct Point3D
{
private:
int* _Coordinates = (int*)malloc(3 * sizeof(int));
public:
int& operator[](int index)
{
return _Coordinates[index];
}
};
int main()
{
Point3D point;
point[0] = 3;
point[1] = 4;
point[2] = 5;
auto const coordOne = point[1];
auto const isFour = point[1] == 4;
point[1] = 0; // line #25, set conditional breakpoint here
// Conditional breakpoints in line 25 using 'Conditional Expression' is 'true' with:
// isFour == true // works
// coordOne == 4 // works
// point[1] == 4 // Error: no operator '[]' matches these operands
}
【问题讨论】:
标签: c++ visual-studio debugging operator-overloading conditional-breakpoint