0

(sorry if this is a noob question) Is there any way to allow fixed size C++ arrays in Visual Studio 2019 Community Edition (i.e int arr[n] where n is the size I want) Thanks in advance :D

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982

1 Answers1

0

No. Variable sized arrays are not part of the C++ standard, and Visual Studio does not implement them. Use std::vector instead.

If you've done measurements that prove that this vector allocation+deallocation is a major slowdown in your app (which I've never seen happen, ever), then consider using a stack-based buffer allocator with the std::vector.

Mooing Duck
  • 64,318
  • 19
  • 100
  • 158
  • Well, difference is that vector would be allocated on heap. What would be more or less equivalent is std::vector with stack based allocator, see https://stackoverflow.com/questions/8049657/stack-buffer-based-stl-allocator – Severin Pappadeux Dec 17 '20 at 19:26