There is a question of choosing the inner container in the classroom.

The length of the container after initialization will not change. In theory, a class implements an n-dimensional model, but in practice the dimension will not exceed 4.

I understand that there will be no noticeable difference, but from the point of view of the internal structure of these classes - which is faster: references to std::array elements or to std::vector elements?

  • 3
    by productivity the same. In terms of readability, the better array (emphasizes a fixed size). - pavel
  • It is curious simply: why, for a size of 4 elements, is there anything in general from std:: ? - PinkTux
  • four
    Check out the container selection algorithm . - αλεχολυτ
  • @PinkTux let's say that. In theory, the class is n-dimensional, but in practice, the dimensions from 2 to 4 are used much more often. - Gordory

1 answer 1

Better std::array - it has no overhead such as allocating / redistributing memory, storing the number of elements, etc.