Assuming the following basic_fixed_string implementation ``` #include <cstdlib> template<typename CharT, std::size_t N> struct basic_fixed_string { CharT data_[N+1] = {}; constexpr basic_fixed_string(const CharT (&txt)[N+1]) noexcept { for(std::size_t i = 0; i <= N; ++i) data_[i] = txt[i]; } // auto operator==(const basic_fixed_string &) = default; }; template<typename CharT, std::size_t N> basic_fixed_string(const CharT (&str)[N]) -> basic_fixed_string<CharT, N-1>; ``` the following works: ``` template<basic_fixed_string Name, typename...> struct A { static constexpr auto name = Name; }; struct B : A<"abc", int> {}; ``` but the following does not work ``` template<basic_fixed_string Name, typename...> struct A; template<basic_fixed_string Name, typename T1> struct A<Name, T1> { static constexpr auto name = Name; }; struct B : A<"abc", int> {}; ``` Fails with the following error: ``` source>:26:18: error: class template argument deduction failed: 26 | struct A<Name, T1> { | ^ <source>:26:18: error: no matching function for call to 'basic_fixed_string(basic_fixed_string<...auto...>)' <source>:16:1: note: candidate: 'template<class CharT, long unsigned int N> basic_fixed_string(const CharT (&)[N])-> basic_fixed_string<CharT, (N - 1)>' 16 | basic_fixed_string(const CharT (&str)[N]) -> basic_fixed_string<CharT, N-1>; | ^~~~~~~~~~~~~~~~~~ <source>:16:1: note: template argument deduction/substitution failed: <source>:26:18: note: mismatched types 'const CharT [N]' and 'basic_fixed_string<...auto...>' 26 | struct A<Name, T1> { | ^ <source>:7:15: note: candidate: 'template<class CharT, long unsigned int N> basic_fixed_string(const CharT (&)[(N + 1)])-> basic_fixed_string<CharT, N>' 7 | constexpr basic_fixed_string(const CharT (&txt)[N+1]) noexcept | ^~~~~~~~~~~~~~~~~~ <source>:7:15: note: template argument deduction/substitution failed: <source>:26:18: note: mismatched types 'const CharT [(N + 1)]' and 'basic_fixed_string<...auto...>' 26 | struct A<Name, T1> { | ^ <source>:4:8: note: candidate: 'template<class CharT, long unsigned int N> basic_fixed_string(basic_fixed_string<CharT, N>)-> basic_fixed_string<CharT, N>' 4 | struct basic_fixed_string { | ^~~~~~~~~~~~~~~~~~ <source>:4:8: note: template argument deduction/substitution failed: <source>:26:18: note: mismatched types 'basic_fixed_string<CharT, N>' and 'basic_fixed_string<...auto...>' 26 | struct A<Name, T1> { | ^ <source>:30:12: error: invalid use of incomplete type 'struct A<basic_fixed_string<char, 3>{"abc"}, int>' 30 | struct B : A<"abc", int> {}; | ^~~~~~~~~~~~~ <source>:23:8: note: declaration of 'struct A<basic_fixed_string<char, 3>{"abc"}, int>' 23 | struct A; | ^ Compiler returned: 1 ``` Godbolt link: https://godbolt.org/z/MCdhTJ
Is the code accepted with clang?
No, it fails on clang with: ``` <source>:22:10: error: use of class template 'basic_fixed_string' requires template arguments; argument deduction not allowed in template parameter template<basic_fixed_string Name, typename...> ^~~~~~~~~~~~~~~~~~ ``` As I understand, argument deduction for template parameters is allowed and supported already by gcc.
This appears to be a dup of PR93083 which has since been fixed for GCC >= 10.3. *** This bug has been marked as a duplicate of bug 93083 ***