为什么我不能编译结构化绑定?

Why can't I compile structured bindings?

我正在尝试编译此代码(在文件 test.cpp 中)

#include<tuple>

int main(){
  auto [c,d] = make_tuple(3.1,2.3);
}

正在使用 g++ -std=c++17 test.cpp -o test , 也 clang++ -std=c++1z test.cpp -o test 两者都会打印错误消息:

test.cpp: In function ‘int main()’:
test.cpp:3:7: error: expected unqualified-id before ‘[’ token
auto [c,d] = make_tuple(3.1,2.3);

正在使用 g++ (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 和 铛版本 3.8.0-2ubuntu4 (使用 Ubuntu 16.04.09) 我错过了什么?

来自GCC官网:

  • gcc 版本 7 支持结构化绑定

来自clang官网:

  • 版本 4 支持结构化绑定。

以下 link 介绍编译器对新 C++ 功能的支持。 https://en.cppreference.com/w/cpp/compiler_support