From 151ed08f53a7fd315602683f515a122484f6778a Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 19 Mar 2023 14:00:23 -0600 Subject: [PATCH] Use std_cxx20::identity_type. --- include/deal.II/base/template_constraints.h | 66 ++------------------- 1 file changed, 6 insertions(+), 60 deletions(-) diff --git a/include/deal.II/base/template_constraints.h b/include/deal.II/base/template_constraints.h index 208a99877e..3f5f3ae36b 100644 --- a/include/deal.II/base/template_constraints.h +++ b/include/deal.II/base/template_constraints.h @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -333,70 +334,15 @@ constexpr bool has_begin_and_end = internal::is_supported_operation; - /** - * A template class that simply exports its template argument as a local - * alias. This class, while at first appearing useless, makes sense in the - * following context: if you have a function template as follows: - * @code - * template - * void f(T, T); - * @endcode - * then it can't be called in an expression like f(1, 3.141) - * because the type T of the template can not be deduced in a - * unique way from the types of the arguments. However, if the template is - * written as - * @code - * template - * void f(T, typename identity::type); - * @endcode - * then the call becomes valid: the type T is not deducible from - * the second argument to the function, so only the first argument - * participates in template type resolution. - * - * The context for this feature is as follows: consider - * @code - * template - * void forward_call(RT (*p) (A), A a) - * { - * p(a); - * } - * - * void h (double); + * A `using` declaration to make the + * [std::identity_type](https://en.cppreference.com/w/cpp/types/type_identity) + * class available under the name that deal.II has used for a long time. * - * void g() - * { - * forward_call(&h, 1); - * } - * @endcode - * This code fails to compile because the compiler can't decide whether the - * template type A should be double (from the - * signature of the function given as first argument to - * forward_call, or int because the expression - * 1 has that type. Of course, what we would like the compiler to - * do is simply cast the 1 to double. We can achieve - * this by writing the code as follows: - * @code - * template - * void forward_call(RT (*p) (A), typename identity::type a) - * { - * p(a); - * } - * - * void h (double); - * - * void g() - * { - * forward_call(&h, 1); - * } - * @endcode + * @deprecated Use `std_cxx20::identity_type` instead. */ template -struct identity -{ - using type = T; -}; - +using identity = std_cxx20::type_identity; /** -- 2.39.5