If an explicit loop is out of the question, use an implicit perhaps. Let the standard library do it for you.
std::transform(a, a + 3, b, c, std::plus<int>{});
If you often do this on arrays of the same size, you can even templatize it:
template<typename T, std::size_t N>
void add_arrays( T (const &a)[N], T (const &b)[N], T (&c)[N] ) {
std::transform(a, a + N, b, c, std::plus<T>{});
}
The compiler will be nice and check the sizes for you. And you don’t even have to stop there. There are many ways to make add_arrays
usable in other contexts.
. . std::array
. , . (, , ), .