相关疑难解决方法(0)

Lambda捕获和具有相同名称的参数 - 谁影响另一个?(clang vs gcc)

auto foo = "You're using g++!";
auto compiler_detector = [foo](auto foo) { std::puts(foo); };
compiler_detector("You're using clang++!");
Run Code Online (Sandbox Code Playgroud)
  • clang ++ 3.6.0和更新的打印出"你正在使用clang ++!" 并警告捕获 foo未被使用.

  • g ++ 4.9.0和更新版本打印出"你正在使用g ++!" 并警告该参数 foo未被使用.

什么编译器更准确地遵循C++标准?

wandbox示例

c++ lambda shadowing language-lawyer c++11

124
推荐指数
2
解决办法
4467
查看次数

标签 统计

c++ ×1

c++11 ×1

lambda ×1

language-lawyer ×1

shadowing ×1