Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions include/daw/daw_iterator_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@

namespace daw {
template<typename It>
using iter_value_t =
typename std::iterator_traits<daw::remove_cvref_t<It>>::value_type;
using iter_reference_t = decltype( *std::declval<It>( ) );

template<typename It>
using iter_reference_t =
typename std::iterator_traits<daw::remove_cvref_t<It>>::reference;
using iter_const_reference_t = decltype( *std::declval<It const>( ) );

template<typename It>
using iter_value_t = std::remove_cvref_t<iter_reference_t<It>>;

template<typename It>
using iter_pointer_t =
Expand All @@ -34,17 +35,13 @@ namespace daw {
using iter_difference_t =
typename std::iterator_traits<daw::remove_cvref_t<It>>::difference_type;

template<typename It>
using iter_const_reference_t =
std::common_reference_t<iter_value_t<It> const &&, iter_reference_t<It>>;

template<typename It>
using iter_category_t =
typename std::iterator_traits<daw::remove_cvref_t<It>>::iterator_category;

template<typename It>
concept Iterator = requires( It & it ) {
{ ++it } -> std::same_as<It &>;
{ ++it }->std::same_as<It &>;
{ it++ };
{ *it };
};
Expand Down Expand Up @@ -170,18 +167,24 @@ namespace daw {
};

template<Range R>
using iterator_t = DAW_TYPEOF( std::begin( std::declval<R>( ) ) );
using iterator_t = DAW_TYPEOF( std::begin( std::declval<R &>( ) ) );

template<Range R>
using iterator_cbegin_t = DAW_TYPEOF( std::cbegin( std::declval<R &>( ) ) );

template<Range R>
using iterator_end_t = DAW_TYPEOF( std::end( std::declval<R &>( ) ) );

template<Range R>
using iterator_end_t = DAW_TYPEOF( std::end( std::declval<R>( ) ) );
using iterator_cend_t = DAW_TYPEOF( std::cend( std::declval<R &>( ) ) );

template<Range R>
using const_iterator_t =
DAW_TYPEOF( std::cbegin( std::declval<R const &>( ) ) );
DAW_TYPEOF( std::cbegin( std::declval<R &>( ) ) );

template<Range R>
using const_iterator_end_t =
DAW_TYPEOF( std::cend( std::declval<R const &>( ) ) );
DAW_TYPEOF( std::cend( std::declval<R &>( ) ) );

template<Range R>
using range_value_t = iter_value_t<iterator_t<R>>;
Expand Down
9 changes: 6 additions & 3 deletions include/daw/pipelines/chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include "daw/cpp_17.h"
#include "daw/daw_attributes.h"
#include "daw/daw_iterator_traits.h"
#include "daw/daw_move.h"
Expand Down Expand Up @@ -54,7 +55,9 @@ namespace daw::pipelines::pimpl {
public:
explicit chunk_view( ) = default;

explicit chunk_view( Range auto &&r )
template<Range U>
requires( not std::same_as<std::remove_reference_t<U>, chunk_view> ) //
explicit chunk_view( U &&r )
: m_range{ DAW_FWD( r ) }
, m_iter{ std::begin( m_range ) } {}

Expand Down Expand Up @@ -119,9 +122,9 @@ namespace daw::pipelines::pimpl {
operator!=( chunk_view const &rhs ) const noexcept = default;
};
template<Range R>
chunk_view( R &&r ) -> chunk_view<R>;
chunk_view( R &&r ) -> chunk_view<daw::remove_rvalue_ref_t<R>>;
template<Range R>
chunk_view( R &&r, std::size_t ) -> chunk_view<R>;
chunk_view( R &&r, std::size_t ) -> chunk_view<daw::remove_rvalue_ref_t<R>>;

struct Chunk_t {
std::size_t chunk_size;
Expand Down
3 changes: 2 additions & 1 deletion include/daw/pipelines/concat.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ namespace daw::pipelines {
}
};
template<typename... Ranges>
concat_view( Ranges &&... ) -> concat_view<Ranges...>;
concat_view( Ranges &&... )
-> concat_view<daw::remove_rvalue_ref_t<Ranges>...>;

namespace pimpl {
struct Concat_t {
Expand Down
23 changes: 9 additions & 14 deletions include/daw/pipelines/flatten.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace daw::pipelines::pimpl {
template<ForwardRange R>
struct flatten_view : range_base_t<flatten_view<R>, flatten_view_end_t<R>> {
using iterator_t = daw::iterator_t<R>;
using sub_iterator_t = daw::iterator_t<daw::iter_value_t<iterator_t>>;
using sub_iterator_t = daw::iterator_t<daw::iter_reference_t<iterator_t>>;
using iterator_category = std::forward_iterator_tag;
using value_type = daw::iter_value_t<sub_iterator_t>;
using reference = daw::iter_reference_t<sub_iterator_t>;
Expand All @@ -50,23 +50,15 @@ namespace daw::pipelines::pimpl {
using end_t = flatten_view_end_t<R>;

using m_range_t = daw::remove_cvrvref_t<R>;
m_range_t m_range;
mutable m_range_t m_range;
iterator_t m_range_first{ };
sub_iterator_t m_cur_first{ };

[[nodiscard]] constexpr auto rabegin( ) {
return std::begin( m_range );
}

[[nodiscard]] constexpr auto rabegin( ) const {
return std::begin( m_range );
}

[[nodiscard]] constexpr iterator_end_t<R> raend( ) {
return std::end( m_range );
}

[[nodiscard]] constexpr iterator_end_t<R> raend( ) const {
[[nodiscard]] constexpr auto raend( ) const {
return std::end( m_range );
}

Expand All @@ -93,7 +85,10 @@ namespace daw::pipelines::pimpl {
public:
explicit flatten_view( ) = default;

explicit constexpr flatten_view( auto &&r )
template<Range U>
requires( not std::same_as<std::remove_cvref_t<U>,
flatten_view> ) //
explicit constexpr flatten_view( U &&r )
: m_range( DAW_FWD( r ) )
, m_range_first( rabegin( ) )
, m_cur_first( m_range_first == raend( )
Expand All @@ -104,7 +99,7 @@ namespace daw::pipelines::pimpl {
return *this;
}

[[nodiscard]] constexpr end_t end( ) const {
[[nodiscard]] constexpr auto end( ) const {
return end_t{ raend( ) };
}

Expand Down Expand Up @@ -152,7 +147,7 @@ namespace daw::pipelines::pimpl {
}
};
template<Range R>
flatten_view( R && ) -> flatten_view<R>;
flatten_view( R && ) -> flatten_view<daw::remove_rvalue_ref_t<R>>;

struct Flatten_t {
[[nodiscard]] DAW_ATTRIB_INLINE DAW_CPP23_STATIC_CALL_OP constexpr auto
Expand Down
6 changes: 3 additions & 3 deletions include/daw/pipelines/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace daw::pipelines {
struct map_iterator {
using iterator_category = daw::iter_category_t<Iterator>;
using value_type = daw::remove_cvref_t<std::invoke_result_t<
Fn, std::invoke_result_t<Projection, daw::iter_value_t<Iterator>>>>;
Fn, std::invoke_result_t<Projection, daw::iter_reference_t<Iterator>>>>;
using reference = value_type;
using const_reference = value_type;
using pointer = arrow_proxy<value_type>;
Expand Down Expand Up @@ -238,9 +238,9 @@ namespace daw::pipelines {
[[nodiscard]] constexpr auto operator( )( auto &&r ) const {
using R = DAW_TYPEOF( r );
static_assert(
std::invocable<Projection, range_value_t<R>>,
std::invocable<Projection, range_reference_t<R>>,
"Projection must be invocable with the range_value_t<R>" );
using projected_t = std::invoke_result_t<Projection, range_value_t<R>>;
using projected_t = std::invoke_result_t<Projection, range_reference_t<R>>;

if constexpr( Range<R> ) {
static_assert( std::invocable<Fn, projected_t>,
Expand Down
14 changes: 8 additions & 6 deletions include/daw/pipelines/slide.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ namespace daw::pipelines::pimpl {
template<ForwardRange R>
struct slide_view {
using iterator = daw::iterator_t<R>;
using const_iterator = daw::iterator_t<std::add_const_t<R>>;
using const_iterator = daw::const_iterator_t<R>;
using iterator_category = daw::range_category_t<R>;
using value_type = range_t<iterator>;
using reference = range_t<iterator>;
using const_reference = range_t<iterator>;
using const_reference = range_t<const_iterator>;
using difference_type = std::ptrdiff_t;
using i_am_a_daw_slide_view_iterator_class = void;

Expand Down Expand Up @@ -55,8 +55,10 @@ namespace daw::pipelines::pimpl {
public:
explicit slide_view( ) = default;

explicit slide_view( Range auto &&r )
: m_range{ DAW_FWD( r ) }
template<Range U>
requires( not std::same_as<std::remove_cvref_t<U>, slide_view> ) //
explicit slide_view( U &&r )
: m_range( DAW_FWD( r ) )
, m_iter{ std::begin( m_range ) } {}

explicit constexpr slide_view( Range auto &&r, std::size_t slide_size )
Expand Down Expand Up @@ -120,9 +122,9 @@ namespace daw::pipelines::pimpl {
operator!=( slide_view const &rhs ) const noexcept = default;
};
template<Range R>
slide_view( R &&r ) -> slide_view<R>;
slide_view( R &&r ) -> slide_view<daw::remove_rvalue_ref_t<R>>;
template<Range R>
slide_view( R &&r, std::size_t ) -> slide_view<R>;
slide_view( R &&r, std::size_t ) -> slide_view<daw::remove_rvalue_ref_t<R>>;

struct Slide_t {
std::size_t slide_size = 1;
Expand Down
Loading
Loading