Very often in C++ class definitions, especially in libraries, trait class etc., you see code similar to the following snippet:
template <typename Bar, typename Baz>
class Foo {
using bar_type = Bar;
using baz_type = Baz;
// ... etc.
}
And only with these lines can you later refer to Foo<A,B>::bar_type
or Foo<C,D>:baz_type
. I'm wondering: Why doesn't the language standard require the compiler to automatically define types using the typename template parameters, i.e. allow removing the two using lines, and recognize Foo<A,B>::Bar
as A
and Foo<C,D>::Baz
as D
?
This should not even break existing code, since within Foo, the identifiers Bar and Baz are already taken anyway.