0

I want to declare a std::array, but the array part gets recognized as cli::array keyword (see Why is "array" marked as a reserved word in Visual-C++?), which means that the std:: doesnt affect it. How can a stop Visual Studio from automatically using namespace cli, or specify that I want to use std::array?

the blue array-word recognized as keyword

The blue array-word recognized as keyword

digito_evo
  • 3,216
  • 2
  • 14
  • 42
Cosemuckel
  • 397
  • 1
  • 8
  • 5
    Did you mean `std::array` (for some `N` like `std::array`)? – Artyer Dec 28 '21 at 14:47
  • Just to be clear: This is about the misinterpretation of the IDE, not the compilation, right? It still compiles as expected (if you fix the template arguments), doesn't it? – user17732522 Dec 28 '21 at 14:48
  • It is just a syntax coloring glitch, it does not stop you from using std::array. If you want to write your code like this, not specifying the array size, then you meant to use std::vector instead. – Hans Passant Dec 28 '21 at 14:57
  • If you don’t want the cli namespace, don’t make a cli project – Taekahn Dec 28 '21 at 15:19
  • @Artyer, jup that was it, thanks! – Cosemuckel Dec 28 '21 at 15:33

1 Answers1

5

std::array accepts two template arguments. One is the type of the elements and the other accepts the number of elements.

If you mean to use a dynamic array, then use std::vector.

akm
  • 338
  • 2
  • 11