【发布时间】:2018-08-17 20:15:51
【问题描述】:
如何使用 https://github.com/gcc-mirror/gcc/blob/gcc-6_3_0-release/libstdc%2B%2B-v3/python/libstdcxx/v6/printers.py 的 StdVectorPrinter 创建自己的输出样式?
IE。使用现有的元素访问工具,但我自己驱动输出。
例如对于
#include <string>
#include <vector>
#include <iostream>
int main(int, char**)
{
std::vector<std::string> data = { "hello", "world", "all", "is", "fine" };
for ( auto && i : data) {
std::cout << i << std::endl;
}
return 0;
}
输出不应是
(gdb) p data
$2 = std::vector of length 5, capacity 5 = {"hello", "world", "all", "is", "fine"}
但是
(gdb) p data
$2 = "hello|world|all|is|fine"
使用 StdVectorPrinter(例如)的通用打印机的骨架代码在哪里?
【问题讨论】: