欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

询问在C++中如何对数组运用std::sort进行排序的操作步骤

最编程 2024-07-30 06:57:50
...
// for container with nested typedefs, non-const version template<class Cont> typename Cont::iterator begin(Cont& c){ return c.begin(); } template<class Cont> typename Cont::iterator end(Cont& c){ return c.end(); } // const version template<class Cont> typename Cont::const_iterator begin(Cont const& c){ return c.begin(); } template<class Cont> typename Cont::const_iterator end(Cont const& c){ return c.end(); } // overloads for C style arrays template<class T, std::size_t N> T* begin(T (&arr)[N]){ return &arr[0]; } template<class T, std::size_t N> T* end(T (&arr)[N]){ return arr + N; }