Skip to content

Commit

Permalink
[FIX] clang-18: char_traits for non-character-types are deprecated
Browse files Browse the repository at this point in the history
`seqan3::sam_file_input::dummy_ref_type` uses `seqan::views::repeat_n`, which uses `seqan3::detail::take_exactly`.
Depending on the range type, `seqan3::detail::take_exactly` will do different things.
The types are checked with `if constexpr (seqan3::detail::is_type_specialisation_of_v<..., ...>)`.
`seqan3::detail::is_type_specialisation_of_v` will use `seqan3::detail::`transfer_template_args_onto`,
which is a type trait exposing a type member that will lead to valid but deprecated templates being instantiated.

E.g., `std::basic_string<seqan3::dna5>` is valid and compiles.
However, `std::basic_string` instantiates `std::char_traits<seqan3::dna5>`.
`std::char_traits` is only defined for the provided character types and
LLVM deprecates other specialisations.

In summary, the trait will instantiate `using type = std::basic_string<seqan3::dna5>;`.
This then generates a deprecation warning or error (with -Werror).

The fix is to simplify `is_type_specialisation_of_v` to not use `transfer_template_args_onto`.

Same is done with `is_value_specialisation_of_v`, even though it does not create any warnings/errors.

`transfer_template_args_onto` is used in other places, while `transfer_template_vargs_onto` is not.
  • Loading branch information
eseiler committed Jun 7, 2024
1 parent 164b7dd commit de751e3
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions include/seqan3/core/detail/template_inspection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,8 @@ struct is_type_specialisation_of : public std::false_type
{};

//!\overload
template <typename source_t, template <typename...> typename target_template>
requires (
!std::same_as<transformation_trait_or_t<transfer_template_args_onto<source_t, target_template>, void>, void>)
struct is_type_specialisation_of<source_t, target_template> :
std::is_same<source_t, transfer_template_args_onto_t<source_t, target_template>>
template <template <typename...> typename source_t, typename... source_args>
struct is_type_specialisation_of<source_t<source_args...>, source_t> : public std::true_type
{};

/*!\brief Helper variable template for seqan3::detail::is_type_specialisation_of (unary_type_trait shortcut).
Expand Down Expand Up @@ -169,11 +166,8 @@ struct is_value_specialisation_of : std::false_type
* \see seqan3::detail::is_type_specialisation_of
* \see seqan3::detail::is_value_specialisation_of_v
*/
template <typename source_t, template <auto...> typename target_template>
requires (
!std::same_as<transformation_trait_or_t<transfer_template_vargs_onto<source_t, target_template>, void>, void>)
struct is_value_specialisation_of<source_t, target_template> :
std::is_same<source_t, transfer_template_vargs_onto_t<source_t, target_template>>
template <template <auto...> typename source_t, auto... source_args>
struct is_value_specialisation_of<source_t<source_args...>, source_t> : public std::true_type
{};

/*!\brief Helper variable template for seqan3::detail::is_value_specialisation_of (unary_type_trait shortcut).
Expand Down

0 comments on commit de751e3

Please sign in to comment.