Skip to content
Snippets Groups Projects
Commit aa238386 authored by Jan Travnicek's avatar Jan Travnicek
Browse files

remove not needed begin for c-arrays

parent 13526bb2
No related branches found
No related tags found
1 merge request!95Many clang-tidy fixes
...@@ -1002,30 +1002,6 @@ auto end ( Container && cont ) -> decltype ( std::forward ( cont ).end ( ) ) { ...@@ -1002,30 +1002,6 @@ auto end ( Container && cont ) -> decltype ( std::forward ( cont ).end ( ) ) {
return 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;
}
/** /**
* \brief * \brief
* Output iterator calling a callback function on assignment * Output iterator calling a callback function on assignment
......
...@@ -259,18 +259,6 @@ auto range ( Container && cont ) -> decltype ( std::forward < Container > ( cont ...@@ -259,18 +259,6 @@ auto range ( Container && cont ) -> decltype ( std::forward < Container > ( cont
return ext::make_iterator_range ( std::forward < Container > ( cont ).begin ( ), std::forward < Container > ( cont ).end ( ) ); return ext::make_iterator_range ( std::forward < Container > ( cont ).begin ( ), std::forward < Container > ( cont ).end ( ) );
} }
   
/**
* Specialization of range for static array.
*
* \param arr the static array
*
* \result the range over all elements of the array
*/
template < class T, size_t N >
constexpr ext::iterator_range < T * > range ( T ( & arr ) [ N ] ) noexcept {
return ext::make_iterator_range ( begin ( arr ), end ( arr ) );
}
} /* namespace ext */ } /* namespace ext */
   
#endif /* __RANGE_HPP_ */ #endif /* __RANGE_HPP_ */
...@@ -5,27 +5,17 @@ ...@@ -5,27 +5,17 @@
#include <alib/list> #include <alib/list>
   
TEST_CASE ( "Range", "[unit][std][bits]" ) { TEST_CASE ( "Range", "[unit][std][bits]" ) {
int arr[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
SECTION ( "Constructor" ) { SECTION ( "Constructor" ) {
ext::iterator_range < int * > ra1 = ext::range ( arr );
ext::vector < int > v1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; ext::vector < int > v1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
   
ext::iterator_range < ext::vector < int >::iterator > rv1 ( v1.begin ( ), v1.end ( ) ); ext::iterator_range < ext::vector < int >::iterator > rv1 ( v1.begin ( ), v1.end ( ) );
   
CHECK ( ( std::equal ( ra1.begin ( ), ra1.end ( ), rv1.begin ( ), rv1.end ( ) ) ) );
auto rv2 = ext::range ( v1 ); auto rv2 = ext::range ( v1 );
   
CHECK ( ( std::equal ( rv1.begin ( ), rv1.end ( ), rv2.begin ( ), rv2.end ( ) ) ) ); CHECK ( ( std::equal ( rv1.begin ( ), rv1.end ( ), rv2.begin ( ), rv2.end ( ) ) ) );
} }
   
SECTION ( "Size" ) { SECTION ( "Size" ) {
ext::iterator_range < int * > ra1 ( arr, arr + sizeof ( arr ) / sizeof ( * arr ) );
CHECK ( ra1.size ( ) == 10 );
ext::vector < int > v1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; ext::vector < int > v1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
   
ext::iterator_range < ext::vector < int >::iterator > rv1 ( v1.begin ( ), v1.end ( ) ); ext::iterator_range < ext::vector < int >::iterator > rv1 ( v1.begin ( ), v1.end ( ) );
......
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