Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] view::async_buffer #1205

Merged
merged 3 commits into from
Sep 5, 2019
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ If possible, provide tooling that performs the changes, e.g. a shell-script.
#### Core
* Added traits for "metaprogramming" with `seqan3::type_list` and type packs.

#### Input/Output

* Asynchronous input (background file reading) supported via seqan3::view::async_input_buffer.

## API changes

#### Argument parser
Expand Down
4 changes: 2 additions & 2 deletions include/seqan3/contrib/parallel/buffer_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class buffer_queue
buffer_queue() : buffer_queue{0u}
{}
buffer_queue(buffer_queue const &) = delete;
buffer_queue(buffer_queue &&) = default;
buffer_queue(buffer_queue &&) = delete;
buffer_queue & operator=(buffer_queue const &) = delete;
buffer_queue & operator=(buffer_queue &&) = default;
buffer_queue & operator=(buffer_queue &&) = delete;
~buffer_queue() = default;

// you can set the initial capacity here
Expand Down
61 changes: 50 additions & 11 deletions include/seqan3/range/detail/inherited_iterator_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ struct empty_type
* \snippet test/unit/range/detail/inherited_iterator_base_test.cpp inherited_iterator_base def
*/
template <typename derived_t, std::input_or_output_iterator base_t>
class inherited_iterator_base : public std::conditional_t<std::is_pointer_v<base_t>, empty_type, base_t>
class inherited_iterator_base : public std::conditional_t<std::is_pointer_v<base_t> || !std::semiregular<base_t>,
empty_type,
base_t>
{
private:
//!\brief Whether this iterator inherits or wraps.
static constexpr bool wrap_base = std::is_pointer_v<base_t> || !std::semiregular<base_t>;
public:
/*!\name Associated types
* \brief All are derived from the base_t.
Expand Down Expand Up @@ -89,15 +94,15 @@ class inherited_iterator_base : public std::conditional_t<std::is_pointer_v<base
//!\brief Delegate to base class if inheriting from non-pointer iterator.
constexpr inherited_iterator_base(base_t it) noexcept(std::is_nothrow_move_constructible_v<base_t>)
//!\cond
requires !std::is_pointer_v<base_t>
requires !wrap_base
//!\endcond
: base_t{std::move(it)}
{}

//!\brief Initialise member if deriving from pointer.
constexpr inherited_iterator_base(base_t it) noexcept
//!\cond
requires std::is_pointer_v<base_t>
requires wrap_base
//!\endcond
: member{std::move(it)}
{}
Expand Down Expand Up @@ -184,11 +189,17 @@ ame Arithmetic operators
return *this_derived();
}

//!\brief Post-increment of non-copyable iterators returns void.
constexpr void operator++(int) noexcept(noexcept(++std::declval<derived_t &>()))
{
++(*this_derived());
rrahn marked this conversation as resolved.
Show resolved Hide resolved
}

//!\brief Post-increment, return previous iterator state.
constexpr derived_t operator++(int) noexcept(noexcept(++std::declval<derived_t &>()) &&
noexcept(derived_t(std::declval<base_t &>())))
//!\cond
requires std::input_iterator<base_t>
requires std::semiregular<base_t>
//!\endcond
{
derived_t cpy{*this_to_base()};
Expand Down Expand Up @@ -295,16 +306,34 @@ ame Arithmetic operators
* \{
*/
//!\brief Dereference operator returns element currently pointed at.
constexpr reference operator*() const noexcept(noexcept(*std::declval<base_t &>()))
constexpr reference operator*() noexcept(noexcept(*std::declval<base_t &>()))
//!\cond
requires std::input_iterator<base_t>
requires std::readable<base_t>
//!\endcond
{
return **this_to_base();
}

//!\brief Dereference operator returns element currently pointed at.
constexpr decltype(auto) operator*() const noexcept(noexcept(*std::declval<base_t const &>()))
//!\cond
requires std::readable<base_t>
//!\endcond
{
return **this_to_base();
}

//!\brief Return pointer to this iterator.
constexpr pointer operator->() const noexcept(noexcept(*std::declval<base_t &>()))
constexpr pointer operator->() noexcept(noexcept(*std::declval<base_t &>()))
//!\cond
requires std::input_iterator<base_t>
//!\endcond
{
return &*this_to_base();
rrahn marked this conversation as resolved.
Show resolved Hide resolved
}

//!\brief Return pointer to this iterator.
constexpr decltype(auto) operator->() const noexcept(noexcept(*std::declval<base_t const &>()))
//!\cond
requires std::input_iterator<base_t>
//!\endcond
Expand All @@ -313,19 +342,29 @@ ame Arithmetic operators
}

//!\brief Return underlying container value currently pointed at.
constexpr decltype(auto) operator[](std::make_signed_t<difference_type> const n) const
constexpr decltype(auto) operator[](std::make_signed_t<difference_type> const n)
rrahn marked this conversation as resolved.
Show resolved Hide resolved
noexcept(noexcept(*std::declval<derived_t &>()) && noexcept(std::declval<derived_t &>() + 3))
//!\cond
requires std::random_access_iterator<base_t>
//!\endcond
{
return *(*this_derived() + n);
}

//!\brief Return underlying container value currently pointed at.
constexpr decltype(auto) operator[](std::make_signed_t<difference_type> const n) const
noexcept(noexcept(*std::declval<derived_t const &>()) && noexcept(std::declval<derived_t const &>() + 3))
//!\cond
requires std::random_access_iterator<base_t>
//!\endcond
{
return *(*this_derived() + n);
}
//!\}

private:
//!\brief If the base is a pointer, we wrap it instead of inheriting.
std::conditional_t<std::is_pointer_v<base_t>, base_t, empty_type> member;
std::conditional_t<wrap_base, base_t, empty_type> member;

//!\brief Befriend the derived type so it can access the private members.
friend derived_t;
Expand All @@ -345,7 +384,7 @@ ame Arithmetic operators
//!\brief Cast this to base type.
constexpr base_t * this_to_base()
{
if constexpr (std::is_pointer_v<base_t>)
if constexpr (wrap_base)
return &member;
else
return static_cast<base_t*>(this);
Expand All @@ -354,7 +393,7 @@ ame Arithmetic operators
//!\copydoc this_to_base
constexpr base_t const * this_to_base() const
{
if constexpr (std::is_pointer_v<base_t>)
if constexpr (wrap_base)
return &member;
else
return static_cast<base_t const *>(this);
Expand Down
Loading