Does typename have to be specified inside template?

Viewed 171

It seems that GCC does not require a typename to be specified inside the template while Clang does.

Consider the following code snippet:

template<
    typename T,
    typename value_type = T::value_type
>
void func(T t) {}

The code above compiles successfully on GCC 10.0.1 when Clang reports the following error message:

❯ clang++ -std=c++20 asdf.cpp
asdf.cpp:3:27: error: missing 'typename' prior to dependent type name 'T::value_type'
    typename value_type = T::value_type
                          ^~~~~~~~~~~~~
                          typename
1 error generated.

Why is this so?

UPDATE 1:

As noted by @Language Lawyer, the first suspicion about typename is a feature of P0634R3 not currently supported by Clang.

UPDATE 2:

I'm going to separate this question as it contains two different topics.

See edit history for more details.

1 Answers
Related