Skip to content
Snippets Groups Projects
Commit 87e22170 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

add universal overloads for begin and end

parent e69fc625
No related branches found
No related tags found
No related merge requests found
...@@ -977,6 +977,54 @@ inline constexpr void retract ( Iterator & i, Distance n ) { ...@@ -977,6 +977,54 @@ inline constexpr void retract ( Iterator & i, Distance n ) {
retractInternal ( i, d, std::__iterator_category ( i ) ); retractInternal ( i, d, std::__iterator_category ( i ) );
} }
   
/**
* Generalization of begin for universaly referenced containers.
*
* \param cont the container to call begin on
*
* \result the begin move iterator
*/
template < class Container >
auto begin ( Container && cont ) -> decltype ( std::forward ( cont ).begin ( ) ) {
return std::forward ( cont ).begin ( );
}
/**
* Generalization of end for universaly referenced containers.
*
* \param cont the container to call end on
*
* \result the end move iterator
*/
template < class Container >
auto end ( Container && cont ) -> decltype ( std::forward ( cont ).end ( ) ) {
return std::forward ( cont ).end ( );
}
/**
* Specialization of begin for static array.
*
* \param arr the static array
*
* \result the begining of the array
*/
template < class T, size_t N >
constexpr T * begin ( T ( & arr ) [ N ] ) noexcept {
return arr;
}
/**
* Specialization of end for static array.
*
* \param arr the static array
*
* \result the one after the last element in the array
*/
template < class T, size_t N >
constexpr T * end ( T ( & arr ) [ N ] ) noexcept {
return arr + N;
}
} /* namespace ext */ } /* namespace ext */
   
#endif /* __ITERATOR_HPP_ */ #endif /* __ITERATOR_HPP_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment