Is the std::array template generally used in practice? If so, why? And does it work faster than regular arrays?

  • 3
    use, not faster. - pavel
  • and not slower - Vladimir Gamalyan

1 answer 1

The std::array template allows you to use the native (sish) array type ( T[] ) as an object of the first class . Those. such an object can be passed to a function and returned from it without fear of implicitly converting an array to a pointer, and thereby losing dimensions.

std::array is an aggregate type, i.e. not having custom constructors and in fact is a normal wrapper over a sish array. In practice, this usually means that it does not carry any extra computational load at runtime, but it cannot work faster than a raw array.

  • one
    I think that the link to its sources (one from possible) will greatly clarify the situation. - KoVadim