[Bug c++/116005] Class template argument deduction for alias templates error in C++20
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Jul 20 05:05:53 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116005
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
If I change the definition of B to:
template <typename T>
using B = A<const T, void>;
Then it works in GCC and MSVC but still fails on clang (but that might be a
clang issue).
Note EDG also rejects it.
```
"<source>", line 20: error: no instance of constructor "A" matches the argument
list
argument types are: (const f<int>)
B b{v};
^
"<source>", line 20: error: cannot deduce class template arguments
B b{v};
^
```
Note for the EDG case I had to use an user defined template class instead of
std::vector. e.g.:
```
template <class T>
struct f
{};
template <typename T1, typename T2>
struct A {
template <typename U>
A(const f<U> &arr) {}
};
template <typename T1, typename T2>
A(f<T1> const &) -> A<const T1, T2>;
template <typename T>
using B = A<T, void>;
int main() {
const f<int> v;
B b{v};
}
```
EDG also accepts it if we change the A definition to the one mentioned at the
top of this comment.
More information about the Gcc-bugs
mailing list