C++ std::begin(c) 对于 vs 2008

C++ std::begin(c) for vs 2008

我需要在 vs 2008 中使用 std::begin/end。 我得到:

'begin' : is not a member of 'std' when I try to compile. Are there any solution?

std::begin/std::end已经在C++11中引入,如果你的编译器太旧不支持,你可以升级你的编译器或者实现自己的功能:

对于 C 数组:

template <typename T, std::size_t N>
T* begin(T (&a)[N]) { return a; }

template <typename T, std::size_t N>
T* end(T (&a)[N]) { return a + N; }