diff --git a/include/seqan3/core/detail/template_inspection.hpp b/include/seqan3/core/detail/template_inspection.hpp index 83309d7a51f..18e46ba637b 100644 --- a/include/seqan3/core/detail/template_inspection.hpp +++ b/include/seqan3/core/detail/template_inspection.hpp @@ -7,6 +7,7 @@ /*!\file * \author Hannes Hauswedell + * \author Lydia Buntrock * \brief Provides type traits for working with templates. */ @@ -235,6 +236,36 @@ struct valid_template_spec_or template typename templ_t, typename ...spec_t> using valid_template_spec_or_t = typename valid_template_spec_or::type; +// ---------------------------------------------------------------------------- +// template_specialisation_of +// ---------------------------------------------------------------------------- + +/*!\addtogroup concept + * \{ + */ + +/*!\interface seqan3::template_specialisation_of <> + * \brief Provides concept `seqan3::template_specialisation_of` for checking the type specialisation of + * some type with a given template, for example a specialized `type_list` with the `type_list` template. + * + * \ingroup type_traits + * + * \tparam mytype The source type. + * \tparam type_template The type template you wish to compare against mytype. + * + * \see seqan3::detail::is_type_specialisation_of_v + * + * ### Example + * + * \include test/snippet/core/detail/template_inspection_usage_3.cpp + */ +//!\cond +template typename type_template> +SEQAN3_CONCEPT template_specialisation_of = is_type_specialisation_of_v; + +//!\endcond +//!\} + // ---------------------------------------------------------------------------- // strip_type_identity // ---------------------------------------------------------------------------- diff --git a/test/snippet/core/detail/template_inspection_usage_3.cpp b/test/snippet/core/detail/template_inspection_usage_3.cpp new file mode 100644 index 00000000000..22e465c4e09 --- /dev/null +++ b/test/snippet/core/detail/template_inspection_usage_3.cpp @@ -0,0 +1,13 @@ +#include + +#include + +int main() +{ + using my_type = std::vector; + + if constexpr (seqan3::detail::template_specialisation_of) // std::vector has no <> ! + { + // ... + } +} diff --git a/test/unit/core/detail/template_inspection_test.cpp b/test/unit/core/detail/template_inspection_test.cpp index d138fd3e821..c45712bf004 100644 --- a/test/unit/core/detail/template_inspection_test.cpp +++ b/test/unit/core/detail/template_inspection_test.cpp @@ -190,3 +190,9 @@ TEST(template_inspect, is_type_specialisation_of_with_ill_formed_non_type_templa { EXPECT_FALSE((seqan3::detail::is_value_specialisation_of_v, constraint_vbar>)); } + +TEST(template_inspect, template_specialisation_of) +{ + EXPECT_TRUE((seqan3::detail::template_specialisation_of, seqan3::type_list>)); + EXPECT_FALSE((seqan3::detail::template_specialisation_of, std::tuple>)); +}