当用作模板函数返回类型时,为什么VC++ 2013拒绝编译嵌套类型,使用using关键字进行visibile?

neu*_*est 7 c++ templates nested multiple-inheritance visual-studio-2013

Visual Studio 2013(更新2)在编译模板函数时抛出编译时错误,该模板函数的返回类型是嵌套类型名称,已通过多重继承隐藏,并使用using关键字再次显示; 如下面的代码所示:

struct Base1
{
  typedef int value_type;
};

struct Base2
{
  typedef double value_type;
};

struct Derived : Base1, Base2
{
  using Base1::value_type;
};

template<typename T>
typename T::value_type nullary_function() { return 0; }

template<typename T>
typename T::value_type unary_function(T t) { return 0; }

int main()
{
  nullary_function<Derived>(); // Error: C2770
  unary_function( Derived() ); // Error: C2893
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

(错误编号取决于函数是否接受模板参数,如注释中所示.)

G ++ 4.7接受此代码.

具体来说,我想知道C++标准在这个问题上有什么说法,以及这是否是VC++编译器错误.(在我看来,using在我知道的情况下,使用关键字使嵌套类型可见,使其在其他所有情况下都可见.

我也知道using关键字的行可能会改变

using Base1::value_type;
Run Code Online (Sandbox Code Playgroud)

typedef Base1::value_type value_type;
Run Code Online (Sandbox Code Playgroud)

为了使代码能够正确编译和运行,但是对于某些(可能)有效的代码在某些编译器而不是其他编译器上进行编译而言,可移植性似乎不好 - 因此需要澄清.

LTh*_*ode 0

这确实是一个编译器错误 - ICC、CLang 和 G++ 都接受此代码并在Godbolt上进行了验证。

我能找到的标准中最适用的语言是 7.3.3 (namespace.udecl) p2 (引用自N3337

每个using 声明都是一个声明和一个成员声明,​​因此可以在类定义中使用。

PS ICC、CLang 和 G++ 也都接受 typedef 版本。