【发布时间】:2015-01-21 20:36:05
【问题描述】:
C++ 中“abc”的类型是什么?候选人可以是 const char* 或 char* 。
还有什么可以想到的吗?
【问题讨论】:
-
其实是
const char[4]。 -
我在使用 c++11 std::regex_replace 时遇到了一个奇怪的 clang++ 编译器行为。编译器不接受:
std::string text = "Quick brown fox";std::regex vowel_re("a|e|i|o|u");错误 -->std::cout << '\n' << std::regex_replace(text, vowel_re, "[$&]") << '\n';有效 -->std::cout << '\n' << std::regex_replace(text, vowel_re, std::string("[$&]")) << '\n'; -
@tisch 这是一个完全无关的问题(我相信你必须通过
std::string{"[$&]"}) -
@Barry 非编译行来自:en.cppreference.com/w/cpp/regex/regex_replace 这就是我想知道的原因。
-
@tisch:然后问这个问题。请注意,示例中的代码运行良好,至少使用 g++ (GCC) 4.9.2。
标签: c++