| 特性 | VS2010 cl | g++ 4.9.3 |
|---|---|---|
| Lambda 表達式 | ✅ 支持 | ✅ 支持 |
| auto 類型推導 | ✅ 支持 | ✅ 支持 |
| 範圍 for 循環 | ❌ 不支持 | ✅ 支持 |
| 原始字符串字面量 R\"(...)\" | ❌ 不支持 | ✅ 支持 |
| std::function / std::bind | ✅ 支持 | ✅ 支持 |
| 右值引用 && | ✅ 部分支持 | ✅ 完全支持 |
| constexpr | ❌ 不支持 | ✅ 支持 |
// Lambda + auto + std::function #include#include std::function getLambda() { return [](int x, int y) { return x * y; }; } int main() { auto f = getLambda(); std::cout << f(6, 7) << std::endl; // 42 // 原始字符串測試 // std::cout << R"delim(a b c)delim"; // VS2010 編譯失敗 return 0; }
VS2010 部分支持 C++11 核心語言特性,但標準庫與新語法(範圍 for、原始字符串、constexpr 等)缺失。建議需完整 C++11 時使用 g++/Clang 或升級 VS 版本。