implicit-instantiation

Is a specialization implicitly instantiated if it has already been implicitly instantiated?

谁说我不能喝 提交于 2019-12-10 02:02:31
问题 The question in the title is clear enough. To be more specific, consider the following example: #include <type_traits> template <typename T> struct is_complete_helper { template <typename U> static auto test(U*) -> std::integral_constant<bool, sizeof(U) == sizeof(U)>; static auto test(...) -> std::false_type; using type = decltype(test((T*)0)); }; template <typename T> struct is_complete : is_complete_helper<T>::type {}; // The above is an implementation of is_complete from https:/

Is a specialization implicitly instantiated if it has already been implicitly instantiated?

随声附和 提交于 2019-12-05 01:27:16
The question in the title is clear enough. To be more specific, consider the following example: #include <type_traits> template <typename T> struct is_complete_helper { template <typename U> static auto test(U*) -> std::integral_constant<bool, sizeof(U) == sizeof(U)>; static auto test(...) -> std::false_type; using type = decltype(test((T*)0)); }; template <typename T> struct is_complete : is_complete_helper<T>::type {}; // The above is an implementation of is_complete from https://stackoverflow.com/a/21121104/5376789 template<class T> class X; static_assert(!is_complete<X<char>>::type{}); //