相关疑难解决方法(0)

如何使用基于范围的for()循环与std :: map?

C++ 11基于范围的()循环的常见示例总是这样简单:

std::vector<int> numbers = { 1, 2, 3, 4, 5, 6, 7 };
for ( auto xyz : numbers )
{
     std::cout << xyz << std::endl;
}
Run Code Online (Sandbox Code Playgroud)

在这种情况下xyz是一个int.但是,当我们有像地图这样的东西时会发生什么?此示例中变量的类型是什么:

std::map< foo, bar > testing = { /*...blah...*/ };
for ( auto abc : testing )
{
    std::cout << abc << std::endl;         // ? should this give a foo? a bar?
    std::cout << abc->first << std::endl;  // ? or is abc an iterator?
}
Run Code Online (Sandbox Code Playgroud)

当遍历的容器很简单时,看起来基于范围的()循环将给我们每个项目,而不是迭代器.哪个好...如果它是迭代器,我们总是要做的第一件事就是取消引用它.

但是,当涉及到地图和多重映射等内容时,我会感到困惑.

(我仍然使用g …

c++ dictionary for-loop c++11

316
推荐指数
4
解决办法
25万
查看次数

如何在OSX上获得"codesigned"gdb?

因为我需要启用Python gdb,所以我通过安装了另一个版本

brew tap homebrew/dupes
brew install gdb
Run Code Online (Sandbox Code Playgroud)

我想在gdbEclipse CDT中使用它,我在调试设置中输入了二进制文件的路径.但是,启动调试程序失败,并显示以下消息:

Error in final launch sequence
Failed to execute MI command:
-exec-run
Error message from debugger back end:
Unable to find Mach task port for process-id 39847: (os/kern) failure (0x5).\n (please check gdb is codesigned - see taskgated(8))
Unable to find Mach task port for process-id 39847: (os/kern) failure (0x5).\n (please check gdb is codesigned - see taskgated(8))
Run Code Online (Sandbox Code Playgroud)

"编码签名"在这种情况下意味着什么?我该如何gdb运行?

c++ debugging macos gdb code-signing

43
推荐指数
4
解决办法
4万
查看次数

标签 统计

c++ ×2

c++11 ×1

code-signing ×1

debugging ×1

dictionary ×1

for-loop ×1

gdb ×1

macos ×1