在for循环中失去范围?

时间:2017-04-20 01:10:18

标签: c++

我正在努力解决这段代码问题。在"调试"模式,它似乎工作。但是,在发布模式下," text"不会出现在for循环的本地中。我看不到发现哈希的文本字符串增长。有什么想法吗?

    std::string checkHashes(std::vector<std::wstring> hashes) {

        std::string text;

        for (int i = 0; i < hashes.size(); i++) {
            if (hashtable[wstring_to_string(hashes[i])] != "") {
                text.resize(text.size() + 33);
                std::string hash = wstring_to_string(hashes[i]);
                text = text + hashtable.find(hash)->second + " ";
            }
        }

        return text;
    }

1 个答案:

答案 0 :(得分:0)

您无法在发布模式下可靠地使用调试器。

如果你想查看每次迭代中包含的'text',你可以使用std :: cout并使用#ifdef DEBUG / #endif或使用静态变量static bool s_debug = false进行有条件的编译,这与条件编译,可以在运行时更改。

相关问题