Skip to content

Commit

Permalink
Adding a few type aliases for AnyIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Nov 8, 2023
1 parent 085d473 commit 01abc51
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
9 changes: 9 additions & 0 deletions src/tools/ranges/AnyIterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,15 @@ class AnyIterator {
}
};

template < typename ValueType >
using AnyInputIterator = AnyIterator< std::input_iterator_tag, ValueType >;
template < typename ValueType >
using AnyForwardIterator = AnyIterator< std::forward_iterator_tag, ValueType >;
template < typename ValueType >
using AnyBidirectionalIterator = AnyIterator< std::bidirectional_iterator_tag, ValueType >;
template < typename ValueType >
using AnyRandomAccessIterator = AnyIterator< std::random_access_iterator_tag, ValueType >;

} // ranges namespace
} // tools namespace
} // njoy namespace
Expand Down
18 changes: 9 additions & 9 deletions src/tools/ranges/AnyIterator/test/AnyIterator.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ SCENARIO( "AnyIterator" ) {

WHEN( "an AnyIterator can be constructed and members can be tested" ) {

AnyIterator< std::forward_iterator_tag, int > begin( values.begin() );
AnyIterator< std::forward_iterator_tag, int > second( ++values.begin() );
AnyIterator< std::forward_iterator_tag, int > end( values.end() );
AnyInputIterator< int > begin( values.begin() );
AnyInputIterator< int > second( ++values.begin() );
AnyInputIterator< int > end( values.end() );

THEN( "the TransformView::Iterator functions as a normal forward iterator" ) {

Expand Down Expand Up @@ -87,9 +87,9 @@ SCENARIO( "AnyIterator" ) {

WHEN( "when the container and the transformation are used" ) {

AnyIterator< std::bidirectional_iterator_tag, int > begin( values.begin() );
AnyIterator< std::bidirectional_iterator_tag, int > second( ++values.begin() );
AnyIterator< std::bidirectional_iterator_tag, int > end( values.end() );
AnyBidirectionalIterator< int > begin( values.begin() );
AnyBidirectionalIterator< int > second( ++values.begin() );
AnyBidirectionalIterator< int > end( values.end() );

THEN( "the TransformView::Iterator functions as a normal bidirectional iterator" ) {

Expand Down Expand Up @@ -151,9 +151,9 @@ SCENARIO( "AnyIterator" ) {

WHEN( "when the container and the transformation are used" ) {

AnyIterator< std::random_access_iterator_tag, int > begin( values.begin() );
AnyIterator< std::random_access_iterator_tag, int > second( ++values.begin() );
AnyIterator< std::random_access_iterator_tag, int > end( values.end() );
AnyRandomAccessIterator< int > begin( values.begin() );
AnyRandomAccessIterator< int > second( ++values.begin() );
AnyRandomAccessIterator< int > end( values.end() );

THEN( "the TransformView::Iterator functions as a normal random access "
"iterator" ) {
Expand Down

0 comments on commit 01abc51

Please sign in to comment.