0

This works in MSVC2017 v15.6, but fails in MSVC2017 v15.7.2:

struct Foo { using T = int; };

template<class DERIVED, class WRAP>
struct A { using T = typename WRAP::T; };

template<class DERIVED>
struct B : public A<DERIVED, Foo> {
  B(T t);  //error C2061: syntax error: identifier 'T'
};

Desired: The using declarations in the BASE are exposed for use in the DERIVED.

The fix for MSVC2017 v15.7.2 seems to be:

template<class DERIVED>
struct B : public A<DERIVED, Foo> {
  using BASE = A<DERIVED, Foo>;
  using T = typename BASE::T;  // ??expose again??
  B(T t);   // OK (MSVC 2018 v15.7.2)
};

Is this a regression in MSVC2017 v15.7.2, or is this expected C++ behavior?

Note that this question is different from:

*- Type not found when derived from template base class

...because why is the public using in the BASE no longer visibile in the DERIVED ?

charley
  • 5,913
  • 1
  • 33
  • 58
  • This is not the basic question about how dependent types work nor the known issues with MSVC. Please refrain from closing the question with answers to the basic question. – dascandy May 31 '18 at 13:57
  • For your last question: `T` is dependent on its template parameters. See https://stackoverflow.com/questions/1527849/how-do-you-understand-dependent-names-in-c – Rakete1111 May 31 '18 at 13:58
  • Agree (`T` is dependent type), but that is resolved in `BASE` through re-exporting from the `Foo` concrete type. It seems nonsensical that `BASE::T` and `DERIVED::T` could resolve to different types when parameterized with concrete type `Foo`. So, why must `DERIVED::T` be explicitly resolved again? – charley May 31 '18 at 14:04

0 Answers0