Using std::array

suggest change

The container std::array can bundle together a fixed number of return values. This number has to be known at compile-time and all return values have to be of the same type:

std::array<int, 4> bar(int a, int b) {
    return { a + b, a - b, a * b, a / b };

This replaces c style arrays of the form int bar[4]. The advantage being that various c++ std functions can now be used on it. It also provides useful member functions like at which is a safe member access function with bound checking, and size which allows you to return the size of the array without calculation.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents