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:

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


Returning multiple values from a function:
* Using std::array

Table Of Contents
8 Arrays
11 Loops
39 Streams
42 Returning multiple values from a function
51 Unions
56 Lambdas
60 SFINAE
62 RAII
67 Sorting
84 RTTI
87 Scopes
104 Profiling
107 Recursion
117 Iteration
125 Alignment
134 Semaphore
136 Debugging
139 Mutexes
142 decltype