Skip to content

Commit

Permalink
Adding a few more use cases to diagnose issues
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Jun 22, 2024
1 parent 0f67156 commit 694f09d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
32 changes: 32 additions & 0 deletions src/tools/std23/test/usecase.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

// other includes
#include <vector>
#include <complex>

// convenience typedefs
using namespace njoy::tools;
Expand All @@ -15,6 +16,8 @@ class TestCase {

std::vector< double > vector_ = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
std::vector< double > other_ = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };

public:

Expand Down Expand Up @@ -111,6 +114,23 @@ class TestCase {
| std20::views::transform( [] ( auto&& values ) { return values.front(); } )
| std20::views::drop( 2 );
}

auto zip_drop_stride() const {

using namespace njoy::tools;
return std23::views::zip(
this->all(),
this->other_ | std20::views::all );
}

auto zip_transform_drop_stride() const {

using namespace njoy::tools;
return std23::views::zip_transform(
[] ( auto&& left, auto&& right ) { return std::complex( left, right ); },
this->all(),
this->other_ | std20::views::all );
}
};

SCENARIO( "use case" ) {
Expand Down Expand Up @@ -200,4 +220,16 @@ SCENARIO( "use case" ) {
CHECK( std20::range< ChunkTransformDrop > );
CHECK( std20::random_access_range< ChunkTransformDrop > );
CHECK( std20::sized_range< ChunkTransformDrop > );

using ZipDropStride = decltype( test.zip_drop_stride() );
CHECK( std20::view< ZipDropStride > );
CHECK( std20::range< ZipDropStride > );
// CHECK( std20::random_access_range< ZipDropStride > );
CHECK( std20::sized_range< ZipDropStride > );

using ZipTransformDropStride = decltype( test.zip_transform_drop_stride() );
// CHECK( std20::view< ZipTransformDropStride > );
// CHECK( std20::range< ZipTransformDropStride > );
// CHECK( std20::random_access_range< ZipTransformDropStride > );
// CHECK( std20::sized_range< ZipTransformDropStride > );
} // SCENARIO
6 changes: 3 additions & 3 deletions src/tools/std23/views/zip_transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ private :
std20::ranges::range_reference_t< maybe_const< Const, Rs > >... > >;
using difference_type = std20::ranges::range_difference_t< Base >;
using iterator_category = std::conditional_t<
zip_all_random_access< Const, Rs... >,
std20::ranges::random_access_range< Base >,
std20::random_access_iterator_tag,
std::conditional_t<
zip_all_bidirectional< Const, Rs... >,
std20::ranges::bidirectional_range< Base >,
std20::bidirectional_iterator_tag,
std::conditional_t<
zip_all_forward< Const, Rs... >,
std20::ranges::forward_range< Base >,
std20::forward_iterator_tag,
std20::input_iterator_tag > > >;

Expand Down

0 comments on commit 694f09d

Please sign in to comment.