Skip to content

Commit

Permalink
Merge pull request #1774 from marehr/fix_cocaseq
Browse files Browse the repository at this point in the history
[FIX] a better fix for concatenated sequences?!
  • Loading branch information
rrahn authored May 11, 2020
2 parents bd85cda + 77c50c3 commit 348e6d8
Showing 1 changed file with 16 additions and 44 deletions.
60 changes: 16 additions & 44 deletions include/seqan3/range/container/concatenated_sequences.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ template <typename inner_type,
//!\cond
requires reservible_container<std::remove_reference_t<inner_type>> &&
reservible_container<std::remove_reference_t<data_delimiters_type>> &&
std::is_same_v<std::ranges::range_size_t<inner_type>, value_type_t<data_delimiters_type>>
std::is_same_v<std::ranges::range_size_t<inner_type>, std::ranges::range_value_t<data_delimiters_type>>
//!\endcond
class concatenated_sequences
{
Expand Down Expand Up @@ -185,69 +185,41 @@ class concatenated_sequences
//!\cond
// unfortunately we cannot specialise the variable template so we have to add an auxiliary here
template <std::ranges::range t>
requires std::convertible_to<std::ranges::range_reference_t<t>, std::ranges::range_value_t<value_type>>
static constexpr bool is_compatible_with_value_type_aux = dimension_v<t> == dimension_v<value_type>;
static constexpr bool is_compatible_with_value_type_aux(std::type_identity<t>)
{
return dimension_v<t> == dimension_v<value_type> &&
std::convertible_to<std::ranges::range_reference_t<t>, std::ranges::range_value_t<value_type>>;
}

static constexpr bool is_compatible_with_value_type_aux(...)
{
return false;
}
//!\endcond

//!\brief Whether a type satisfies seqan3::compatible with this class's `value_type` or `reference` type.
//!\hideinitializer
// we explicitly check same-ness, because these types may not be fully resolved, yet
template <std::ranges::range t>
static constexpr bool is_compatible_with_value_type =
std::is_same_v<remove_cvref_t<t>, value_type> ||
std::is_same_v<remove_cvref_t<t>, reference> ||
std::is_same_v<remove_cvref_t<t>, const_reference> ||
(
!std::same_as<remove_cvref_t<t>, iterator> &&
!std::same_as<remove_cvref_t<t>, const_iterator> &&
!std::same_as<remove_cvref_t<t>, concatenated_sequences> &&
is_compatible_with_value_type_aux<t>
);

//!\cond
// unfortunately we cannot specialise the variable template so we have to add an auxiliary here
template <typename t>
requires std::ranges::range<std::iter_reference_t<t>> &&
(dimension_v<std::iter_reference_t<t>> == dimension_v<value_type>) &&
is_compatible_with_value_type<std::iter_reference_t<t>>
static constexpr bool iter_value_t_is_compatible_with_value_type_aux = true;

template <std::ranges::range t>
requires std::ranges::range<std::ranges::range_reference_t<t>> &&
(dimension_v<std::ranges::range_reference_t<t>> == dimension_v<value_type>) &&
is_compatible_with_value_type<std::ranges::range_reference_t<t>>
static constexpr bool range_value_t_is_compatible_with_value_type_aux = true;
//!\endcond
static constexpr bool is_compatible_with_value_type = is_compatible_with_value_type_aux(std::type_identity<t>{});

//!\brief Whether a type satisfies seqan3::compatible with this class.
//!\hideinitializer
// cannot use the concept, because this class is not yet fully defined
template <typename t>
//!\cond
requires std::ranges::range<std::iter_reference_t<t>>
requires is_compatible_with_value_type<std::iter_reference_t<t>>
//!\endcond
static constexpr bool iter_value_t_is_compatible_with_value_type =
!std::is_same_v<remove_cvref_t<t>, concatenated_sequences> &&
(
std::is_same_v<remove_cvref_t<t>, iterator> ||
std::is_same_v<remove_cvref_t<t>, const_iterator> ||
iter_value_t_is_compatible_with_value_type_aux<t>
);
static constexpr bool iter_value_t_is_compatible_with_value_type = true;

//!\brief Whether a type satisfies seqan3::compatible with this class.
//!\hideinitializer
// cannot use the concept, because this class is not yet fully defined
template <std::ranges::range t>
//!\cond
requires std::ranges::range<std::ranges::range_reference_t<t>>
requires is_compatible_with_value_type<std::ranges::range_reference_t<t>>
//!\endcond
static constexpr bool range_value_t_is_compatible_with_value_type =
!std::is_same_v<remove_cvref_t<t>, iterator> &&
!std::is_same_v<remove_cvref_t<t>, const_iterator> &&
(
std::is_same_v<remove_cvref_t<t>, concatenated_sequences> ||
range_value_t_is_compatible_with_value_type_aux<t>
);
static constexpr bool range_value_t_is_compatible_with_value_type = true;
//!\}

public:
Expand Down

0 comments on commit 348e6d8

Please sign in to comment.