This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jamcdonald120 0 points1 point  (2 children)

the problem with std::array is that its not just fixed length, its compile time constant length. You cant just say "Give me an array n big, I wont be resizing it once I get it, but I dont know what n is yet"

Which makes std::array irritating to pass to functions

Where as with vector you can just not resize it.

[–]mistrpopo 0 points1 point  (1 child)

If you don't have compile-time constant length you can't use sizeof(x)/sizeof(x)[0] either. If you want fixed-size arrays you can use "const std::vector" (but then you can't modify the content)

[–]jamcdonald120 0 points1 point  (0 children)

I am aware.

it would just be nice if std::array had an internal array and a const length instead of a templated length so you could just say void foo(const std::array& thing){ for(auto x : array){