gpt4 book ai didi

C++ std::array 警告

转载 作者:太空狗 更新时间:2023-10-29 23:45:56 26 4
gpt4 key购买 nike

关于下面的代码

std::array<int,3> myarray = {10,20,30};

我收到以下编译器警告

warning: missing braces around initializer for ‘std::array<int, 3u>::value_type [3] {aka int [3]}’ [-Wmissing-braces]

为什么?

工具链:(编辑)

g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

最佳答案

试试这个:

std::array<int,3> = {{10, 20, 30}}

我认为这是他们在 > 4.6 版本中修复的错误

关于C++ std::array 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14794490/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com