Class C++17 中的模板参数类型推导 - 编译问题

Class template argument type deduction in C++17 - compilation problems

我正在学习 Kate Gregory 在 Pluralsight 上的 C++ 课程,了解到 C++17 为编译器引入了一个功能来推断模板中的类型,但是下面的代码 returns 错误:缺少模板参数在 'numbers'

之前
#include <vector>

using std::vector;

int main()
{
    vector numbers{ 0, 1, 2 };
    return 0;
}

我正在使用 MinGW gcc 编译器(版本 6.3.0)并在命令提示符中使用“g++ -std=c++1z *.cpp”,所以我不确定自己在做什么错了。

我知道我可以通过声明类型来修复它,但我想检查以防我因一些基本错误而错过其他 C++17 功能。

你的代码没问题(但我建议不要使用using std::vector)。

问题是您的编译器 g++ 6.3.0 太旧,无法支持您尝试使用的功能:class template argument deduction 和演绎指南。

You need g++ 7 or newer.