为什么mem_fn在与smatch::str一起使用时编译失败?
Why is mem_fn failing to compile when used with smatch::str?
这看起来很简单,但在调用f(m)
时出现了"失败的替换"页面。为什么呢?
string const input = "The quick brown fox.";
std::regex const words("[^\s]+");
auto f = std::mem_fn(&std::smatch::str);
std::sregex_iterator i = std::sregex_iterator(input.begin(), input.end(), words);
std::smatch m = *i;
string first_word = f(m);
http://ideone.com/nsN8A1 因为str
接受参数。通常默认为0
,但mem_fn
没有缺省参数值,因此必须显式提供。
string first_word = f(m, 0);
http://ideone.com/nfuTFX 相关文章:
- 包含模板文件的递归会导致编译失败
- 提升 1.64 单元测试编译失败
- C++模板的模板编译失败
- 使用已删除的函数进行编译失败,并显示 uclibc
- MinGW-w64 编译失败,nullptr_t
- 使用提升线程时编译失败
- 编译花絮 g++, clang++, 使用 libboost -- g++8 编译失败时 g++7 成功;
- CMake + Qt,moc 编译失败,无法实现 QMetaObject 方法(编译器找不到基本 ui 对象的标头?
- 带有引用的std::tuple在clang中编译失败,但在gcc中编译失败
- 解决由于在哈希函数中使用了不完整的类型而导致的编译失败
- 将XCode升级到verison 11.1后,C++编译失败
- 添加类型名会导致程序编译失败
- 将 qi::lexeme 添加到灵气中的规则时编译失败
- 如果我在下面的代码中使用 list 而不是 vector,为什么在我尝试在迭代器之间执行减法的行中编译失败?
- 返回 std::stringstream - 编译失败
- 编译失败:strlen 不是 std 的成员
- MSBuidel - 将资源文件添加到项目后静态库编译失败
- C++ - 在 std::thread 中调用重载函数时编译失败
- QtWebEngine 到嵌入式 Linux 交叉编译失败
- 使用 glibc 2.7 包含路径编译失败