With C ++ 2011 you want to use
std::copy(std::begin(A), std::end(A), std::back_inserter(my_vector));
... or
std::vector<int> my_vector(std::begin(A), std::end(A));
... or, in fact:
std::vector<int> my_vector({ 10, 20, 30, 40, 50, 60, 70, 80, 90 });
If you do not have C ++ 2011, you want to define
namespace whatever { template <typename T, int Size> T* begin(T (&array)[Size]) { return array; } template <typename T, int Size> T* end(T (&array)[Size]) { return array + Size; } }
and use whatever::begin() and whatever::end() along with one of the first two approaches.
source share