Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ std::array warning

Tags:

c++

arrays

stl

On the following code

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

I am receiving the following compiler warning

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

Why ?

toolchain: (edit)

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.
like image 489
Aditya Sihag Avatar asked Jun 26 '26 09:06

Aditya Sihag


1 Answers

Try this:

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

I think this was a bug they fixed in versions > 4.6

like image 121
Tyler Jandreau Avatar answered Jun 27 '26 22:06

Tyler Jandreau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!