【发布时间】:2018-07-22 03:03:05
【问题描述】:
我目前正在为我自己的类型开发数据格式化程序。但是,我在打印参考文献时遇到了一些问题。
#include <iostream>
class Circle
{
protected:
double R;
double a;
double b;
public:
Circle():R(1), a(0), b(0)
{
}
};
int main()
{
Circle A;
Circle & B = A;
return 0;
}
我使用type summary add 自定义我自己的数据格式化程序
(lldb) type summary add -s "The circle is (R = ${var.R}, a = ${var.a}, b = ${var.b})" Circle
现在对于非引用来说效果很好,例如
(lldb) frame variable A
(Circle) A = The circle is (R = 1, a = 0, b = 0)
但是,对于参考,
(lldb) frame variable B
(Circle &const) B = 0x00007fffffffd200 The circle is (R = 1, a = 0, b = 0): {
R = 1
a = 0
b = 0
}
不需要“:”后面的内容。
我应该如何处理引用?我知道可以使用--skip-references 来禁用引用的输出,但我希望我可以像通常的类型一样格式化引用。
【问题讨论】: