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

Rename concepts to be standard conform #1860

Merged
merged 8 commits into from
Jun 5, 2020
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ Note that 3.1.0 will be the first API stable release and interfaces in this rele

## API changes

* In accordance with the standard, the following concepts are renamed:
* `default_constructible` to `default_initializable`
* `readable` to `indirectly_readable`
* `writable` to `indirectly_writable` ([\#1860](https://github.com/seqan/seqan3/pull/1860)).

#### Range

* The `seqan3::begin()`, `seqan3::end()`, `seqan3::cbegin()`, `seqan3::cend()`, `seqan3::size()`, `seqan3::empty()`
Expand Down
2 changes: 1 addition & 1 deletion doc/howto/write_a_view/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ the same as of the underlying range, we just pass it through.

For many more complex views you will have to define the sentinel type yourself or derive it from the underlying
type in a similar manner to how we derived the iterator type.
Often you can use `std::ranges::default_sentinel_t` as the type for your sentinel and implement the
Often you can use `std::default_sentinel_t` as the type for your sentinel and implement the
"end-condition" in the iterator's equality comparison operator against that type.

\snippet doc/howto/write_a_view/solution_view.cpp view_constructors
Expand Down
2 changes: 1 addition & 1 deletion doc/howto/write_a_view/solution_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class my_view : public std::ranges::view_interface<my_view<urng_t>>
//![view_deduction_guide]
// A deduction guide for the view class template
template <std::ranges::viewable_range orng_t>
my_view(orng_t &&) -> my_view<std::ranges::all_view<orng_t>>;
my_view(orng_t &&) -> my_view<std::views::all_t<orng_t>>;
//![view_deduction_guide]

//![adaptor_type_definition]
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/argument_parser/solution3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ number_type to_number(range_type && range)
{
std::string str;
number_type num;
std::ranges::copy(range, std::ranges::back_inserter(str));
std::ranges::copy(range, std::cpp20::back_inserter(str));
auto res = std::from_chars(&str[0], &str[0] + str.size(), num);

if (res.ec != std::errc{})
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/argument_parser/solution4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ number_type to_number(range_type && range)
{
std::string str;
number_type num;
std::ranges::copy(range, std::ranges::back_inserter(str));
std::ranges::copy(range, std::cpp20::back_inserter(str));
auto res = std::from_chars(&str[0], &str[0] + str.size(), num);

if (res.ec != std::errc{})
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/argument_parser/solution5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ number_type to_number(range_type && range)
{
std::string str;
number_type num;
std::ranges::copy(range, std::ranges::back_inserter(str));
std::ranges::copy(range, std::cpp20::back_inserter(str));
auto res = std::from_chars(&str[0], &str[0] + str.size(), num);

if (res.ec != std::errc{})
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/argument_parser/solution6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ number_type to_number(range_type && range)
{
std::string str;
number_type num;
std::ranges::copy(range, std::ranges::back_inserter(str));
std::ranges::copy(range, std::cpp20::back_inserter(str));
auto res = std::from_chars(&str[0], &str[0] + str.size(), num);

if (res.ec != std::errc{})
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/sequence_file/sequence_file_solution2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main()
// }

// But you can also do this:
std::ranges::copy(fin, std::ranges::back_inserter(records));
std::ranges::copy(fin, std::cpp20::back_inserter(records));

seqan3::debug_stream << records << '\n';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,26 +368,26 @@ class alignment_matrix_column_major_range_base
* \{
*/
//!\brief Returns `true` if the behind-the-end column was reached, `false` otherwise.
constexpr bool operator==(std::ranges::default_sentinel_t const &) const noexcept
constexpr bool operator==(std::default_sentinel_t const &) const noexcept
{
return column_index == me_ptr->num_cols;
}

//!\copydoc operator==
friend constexpr bool operator==(std::ranges::default_sentinel_t const & lhs, iterator_type const & rhs)
friend constexpr bool operator==(std::default_sentinel_t const & lhs, iterator_type const & rhs)
noexcept
{
return rhs == lhs;
}

//!\brief Returns `true` if the behind-the-end column was not reached, `false` otherwise.
constexpr bool operator!=(std::ranges::default_sentinel_t const & rhs) const noexcept
constexpr bool operator!=(std::default_sentinel_t const & rhs) const noexcept
{
return !(*this == rhs);
}

//!\copydoc operator!=
friend constexpr bool operator!=(std::ranges::default_sentinel_t const & lhs, iterator_type const & rhs)
friend constexpr bool operator!=(std::default_sentinel_t const & lhs, iterator_type const & rhs)
noexcept
{
return rhs != lhs;
Expand Down Expand Up @@ -488,7 +488,7 @@ class alignment_matrix_column_major_range_base
//!\brief The type of the iterator.
using iterator = iterator_type;
//!\brief The type of sentinel.
using sentinel = std::ranges::default_sentinel_t;
using sentinel = std::default_sentinel_t;

public:
/*!\name Iterators
Expand All @@ -510,7 +510,7 @@ class alignment_matrix_column_major_range_base
//!\brief Returns a sentinel marking the end of the matrix.
constexpr sentinel end() noexcept
{
return std::ranges::default_sentinel;
return std::default_sentinel;
}

//!\brief Deleted end for const-qualified alignment matrix.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ class alignment_trace_matrix_full :

using matrix_iter_t = std::ranges::iterator_t<typename matrix_base_t::pool_type>;
using trace_iterator_t = trace_iterator<matrix_iter_t>;
using path_t = std::ranges::subrange<trace_iterator_t, std::ranges::default_sentinel_t>;
using path_t = std::ranges::subrange<trace_iterator_t, std::default_sentinel_t>;

if (trace_begin.row >= matrix_base_t::num_rows || trace_begin.col >= matrix_base_t::num_cols)
throw std::invalid_argument{"The given coordinate exceeds the matrix in vertical or horizontal direction."};

return path_t{trace_iterator_t{matrix_base_t::data.begin() + matrix_offset{trace_begin}},
std::ranges::default_sentinel};
std::default_sentinel};
}

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ class alignment_trace_matrix_full_banded :

using matrix_iter_t = std::ranges::iterator_t<typename matrix_base_t::pool_type>;
using trace_iterator_t = trace_iterator_banded<matrix_iter_t>;
using path_t = std::ranges::subrange<trace_iterator_t, std::ranges::default_sentinel_t>;
using path_t = std::ranges::subrange<trace_iterator_t, std::default_sentinel_t>;

if (trace_begin.row >= static_cast<size_t>(band_size) || trace_begin.col >= matrix_base_t::num_cols)
throw std::invalid_argument{"The given coordinate exceeds the trace matrix size."};

return path_t{trace_iterator_t{matrix_base_t::data.begin() + matrix_offset{trace_begin},
column_index_type{band_col_index}},
std::ranges::default_sentinel};
std::default_sentinel};
}

//!\brief The column index where the upper bound of the band passes through.
Expand Down
14 changes: 7 additions & 7 deletions include/seqan3/alignment/matrix/detail/trace_iterator_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@ class trace_iterator_base
}

//!\brief Returns `true` if the pointed-to-element is seqan3::detail::trace_directions::none.
constexpr friend bool operator==(derived_t const & lhs, std::ranges::default_sentinel_t const &) noexcept
constexpr friend bool operator==(derived_t const & lhs, std::default_sentinel_t const &) noexcept
{
return *lhs.matrix_iter == trace_directions::none;
}

//!\brief copydoc operator==()
constexpr friend bool operator==(std::ranges::default_sentinel_t const &, derived_t const & rhs) noexcept
constexpr friend bool operator==(std::default_sentinel_t const &, derived_t const & rhs) noexcept
{
return rhs == std::ranges::default_sentinel;
return rhs == std::default_sentinel;
}

//!\brief Returns `true` if both iterators are not equal, `false` otherwise.
Expand All @@ -217,15 +217,15 @@ class trace_iterator_base
}

//!\brief Returns `true` if the pointed-to-element is not seqan3::detail::trace_directions::none.
constexpr friend bool operator!=(derived_t const & lhs, std::ranges::default_sentinel_t const &) noexcept
constexpr friend bool operator!=(derived_t const & lhs, std::default_sentinel_t const &) noexcept
{
return !(lhs == std::ranges::default_sentinel);
return !(lhs == std::default_sentinel);
}

//!\brief copydoc operator!=()
constexpr friend bool operator!=(std::ranges::default_sentinel_t const &, derived_t const & rhs) noexcept
constexpr friend bool operator!=(std::default_sentinel_t const &, derived_t const & rhs) noexcept
{
return !(rhs == std::ranges::default_sentinel);
return !(rhs == std::default_sentinel);
}
//!\}

Expand Down
14 changes: 7 additions & 7 deletions include/seqan3/alignment/pairwise/alignment_range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ class alignment_range
* The alignment range is an input range and the end is reached when the internal buffer over the alignment
* results has signaled end-of-stream.
*/
constexpr std::ranges::default_sentinel_t end() noexcept
constexpr std::default_sentinel_t end() noexcept
{
return std::ranges::default_sentinel;
return std::default_sentinel;
}

//!\brief This range is not const-iterable.
constexpr std::ranges::default_sentinel_t end() const = delete;
constexpr std::default_sentinel_t end() const = delete;
//!\}

protected:
Expand Down Expand Up @@ -235,27 +235,27 @@ class alignment_range<alignment_executor_type>::alignment_range_iterator
*/
//!\brief Checks whether lhs is equal to the sentinel.
friend constexpr bool operator==(alignment_range_iterator const & lhs,
std::ranges::default_sentinel_t const &) noexcept
std::default_sentinel_t const &) noexcept
{
return lhs.at_end;
}

//!\brief Checks whether `lhs` is equal to `rhs`.
friend constexpr bool operator==(std::ranges::default_sentinel_t const & lhs,
friend constexpr bool operator==(std::default_sentinel_t const & lhs,
alignment_range_iterator const & rhs) noexcept
{
return rhs == lhs;
}

//!\brief Checks whether `*this` is not equal to the sentinel.
friend constexpr bool operator!=(alignment_range_iterator const & lhs,
std::ranges::default_sentinel_t const & rhs) noexcept
std::default_sentinel_t const & rhs) noexcept
{
return !(lhs == rhs);
}

//!\brief Checks whether `lhs` is not equal to `rhs`.
friend constexpr bool operator!=(std::ranges::default_sentinel_t const & lhs,
friend constexpr bool operator!=(std::default_sentinel_t const & lhs,
alignment_range_iterator const & rhs) noexcept
{
return rhs != lhs;
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/argument_parser/detail/format_help.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ class format_help : public format_help_base<format_help>
std::istringstream iss(text.c_str());
std::vector<std::string> tokens;
std::ranges::copy(std::istream_iterator<std::string>(iss), std::istream_iterator<std::string>(),
std::ranges::back_inserter(tokens));
std::cpp20::back_inserter(tokens));

// Print the text.
assert(pos <= tab);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/argument_parser/validators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class value_list_validator
value_list_validator(range_type rng)
{
values.clear();
std::ranges::move(std::move(rng), std::ranges::back_inserter(values));
std::ranges::move(std::move(rng), std::cpp20::back_inserter(values));
}

/*!\brief Constructing from a parameter pack.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class algorithm_executor_blocking
* \{
*/
//!\brief The underlying resource type.
using resource_type = std::ranges::all_view<resource_t>;
using resource_type = std::views::all_t<resource_t>;
//!\brief The iterator over the underlying resource.
using resource_iterator_type = std::ranges::iterator_t<resource_type>;
//!\}
Expand Down
4 changes: 2 additions & 2 deletions include/seqan3/core/detail/pack_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ constexpr bool all_of(unary_predicate_t && fn, pack_t && ...args)
* * call the parameter pack version of seqan3::detail::all_of with the instances of std::identity (as a pack).
*
* Note that wrapping the types in std::type_identity is a technical trick to make a type representable as a value.
* Instantiating a type might not work because they might not be std::default_constructible.
* Instantiating a type might not work because they might not be std::default_initializable.
* In addition it is possible, to invoke the predicate on incomplete types.
*
* ### Example
Expand Down Expand Up @@ -216,7 +216,7 @@ constexpr void for_each(unary_function_t && fn, pack_t && ...args)
* * call the parameter pack version of seqan3::detail::for_each with the instances of std::identity (as a pack).
*
* Note that wrapping the types in std::type_identity is a technical trick to make a type representable as a value.
* Instantiating a type might not work because they might not be std::default_constructible.
* Instantiating a type might not work because they might not be std::default_initializable.
* In addition, it is possible to invoke the unary function on incomplete types.
*
* ### Example
Expand Down
16 changes: 8 additions & 8 deletions include/seqan3/core/simd/view_to_simd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class view_to_simd : public std::ranges::view_interface<view_to_simd<urng_t, sim
"The underlying range must model forward_range.");
static_assert(std::ranges::input_range<std::ranges::range_value_t<urng_t>>,
"Expects the value type of the underlying range to be an input_range.");
static_assert(std::default_constructible<std::ranges::range_value_t<urng_t>>,
static_assert(std::default_initializable<std::ranges::range_value_t<urng_t>>,
"Expects the inner range to be default constructible.");
static_assert(semialphabet<std::ranges::range_value_t<std::ranges::range_value_t<urng_t>>>,
"Expects semi-alphabet as value type of the inner range.");
Expand Down Expand Up @@ -155,9 +155,9 @@ class view_to_simd : public std::ranges::view_interface<view_to_simd<urng_t, sim
constexpr void cbegin() const noexcept = delete;

//!\brief A sentinel representing the end of this range.
constexpr std::ranges::default_sentinel_t end() noexcept
constexpr std::default_sentinel_t end() noexcept
{
return std::ranges::default_sentinel;
return std::default_sentinel;
}

//!\brief Const iteration is disabled.
Expand Down Expand Up @@ -316,25 +316,25 @@ class view_to_simd<urng_t, simd_t>::iterator_type
* \{
*/
//!\brief Returns `true` if iterator reached the end, otherwise `false`.
constexpr bool operator==(std::ranges::default_sentinel_t const &) const noexcept
constexpr bool operator==(std::default_sentinel_t const &) const noexcept
{
return at_end;
}

//!\copydoc seqan3::detail::view_to_simd::iterator_type::operator==
friend constexpr bool operator==(std::ranges::default_sentinel_t const &, iterator_type const & rhs) noexcept
friend constexpr bool operator==(std::default_sentinel_t const &, iterator_type const & rhs) noexcept
{
return rhs.at_end;
}

//!\brief Returns `true` if iterator did not reach the end yet, otherwise `false`.
constexpr bool operator!=(std::ranges::default_sentinel_t const &) const noexcept
constexpr bool operator!=(std::default_sentinel_t const &) const noexcept
{
return !at_end;
}

//!\copydoc seqan3::detail::view_to_simd::iterator_type::operator!=
friend constexpr bool operator!=(std::ranges::default_sentinel_t const &, iterator_type const & rhs) noexcept
friend constexpr bool operator!=(std::default_sentinel_t const &, iterator_type const & rhs) noexcept
{
return !rhs.at_end;
}
Expand Down Expand Up @@ -723,7 +723,7 @@ namespace seqan3::views
*
* * `urng_t` is the type of the range modified by this view (input).
* * the expression `std::ranges::input_range<std::ranges::range_value_t<urng_t>` must evaluate to `true`
* * the expression `std::default_constructible<std::ranges::range_value_t<urng_t>>` must evaluate to `true`
* * the expression `std::default_initializable<std::ranges::range_value_t<urng_t>>` must evaluate to `true`
* * the expression `semialphabet<std::ranges::range_value_t<std::ranges::range_value_t<urng_t>>>` must evaluate to `true`
* * `rrng_type` is the type of the range returned by this view.
* * for more details, see \ref views.
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/io/alignment_file/format_sam_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ inline void format_sam_base::read_field(stream_view_type && stream_view, target_
{
if (!is_char<'*'>(*std::ranges::begin(stream_view)))
std::ranges::copy(stream_view | views::char_to<std::ranges::range_value_t<target_range_type>>,
std::ranges::back_inserter(target));
std::cpp20::back_inserter(target));
else
std::ranges::next(std::ranges::begin(stream_view)); // skip '*'
}
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/io/alignment_file/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ class alignment_file_input
//!\brief The const iterator type is void because files are not const-iterable.
using const_iterator = void;
//!\brief The type returned by end().
using sentinel = std::ranges::default_sentinel_t;
using sentinel = std::default_sentinel_t;
//!\}

/*!\name Constructors, destructor and assignment
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/io/alignment_file/output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class alignment_file_output
//!\brief The const iterator type is void, because files are not const-iterable.
using const_iterator = void;
//!\brief The type returned by end().
using sentinel = std::ranges::default_sentinel_t;
using sentinel = std::default_sentinel_t;
//!\}

/*!\name Constructors, destructor and assignment
Expand Down
Loading