C++ 是通过C+中的typedefs非标准行为消除歧义+;?

C++ 是通过C+中的typedefs非标准行为消除歧义+;?,c++,standards,C++,Standards,,在其中一条评论中,我被告知这可能是非标准行为(尤其是向上移动层级): struct f1 { int运算符()(int a,int b)常量{返回a+b;} }; 结构f2 { int运算符()(int a,int b)常量{返回a*b;} }; 结构f3:f2 { 类型定义f2基本类型; int运算符()(int a,int b)常量 {return base_type::operator()(a,b)*(a/b);} }; 结构f4 { int运算符()(int a,int b)常量{返回

,在其中一条评论中,我被告知这可能是非标准行为(尤其是向上移动层级):

struct f1
{
int运算符()(int a,int b)常量{返回a+b;}
};
结构f2
{
int运算符()(int a,int b)常量{返回a*b;}
};
结构f3:f2
{
类型定义f2基本类型;
int运算符()(int a,int b)常量
{return base_type::operator()(a,b)*(a/b);}
};
结构f4
{
int运算符()(int a,int b)常量{返回a-b;}
};
结构f5:f4
{
类型定义f4基本类型;
int运算符()(int a,int b)常量
{return base_type::operator()(a,b)*a*b;}
};
模板
foo类:F1、F3、F5
{
类型定义F1基本类型1;
类型定义F3基本类型3;
typedef F5基本类型5;
公众:
intf1(inta,intb){returnbase_type_1()(a,b);}
intf3(inta,intb){returnbase_type_3()(a,b);}
intf5(inta,intb){returnbase_type_5()(a,b);}
内部f3f2(内部a、内部b)
{ 
返回base_type_3::base_type::operator()(a,b)*
基本类型3::运算符()(a,b);
}
内部f5f4(内部a、内部b)
{ 
返回base_type_5::base_type::operator()(a,b)*
基本类型:运算符()(a,b);
}
};
int main()
{
福福;
f、 f1(1,2);
f、 f3(1,4);
f、 f5(1,5);
f、 f3f2(1,1);
f、 f5f4(2,2);
返回0;
}

编辑:这是在VC++2008下编译的,第4级没有警告。

IIRC,这是一个98标准禁止使用typedef名称的上下文(我手头没有副本可供检查),而2011标准似乎允许使用它(语法产品在这里使用类型名,类型名的定义允许使用typedef name,并且我没有发现其他文本阻止它在本例中的使用)。

我认为ISO/IEC 14882:2003中不清楚这种情况。尽管它说:

3.4.31/1 Qualified name lookup
...
If the name found is not a class-name (clause 9) or namespace-name (7.3.1),
the program is ill-formed.
关于类名的构成,还有一个悬而未决的问题:

…如果您查看7.1.5.3,详细的类型说明符似乎包括从属名称,但没有明确允许
typedef
关键字。这似乎是2003版标准中的意外遗漏。间接证据:在未启用C++0x扩展的严格模式下,Comeau编译器接受您的代码

然而,ISO/IEC 14882:2011明确规定了以这种方式使用从属名称的有效性。以下是相关措辞:

3.4.3/1 Qualified name lookup
...
If a :: scope resolution operator in a nested-name-specifier is not preceded
by a decltype-specifier, lookup of the name preceding that :: considers only 
namespaces, types, and templates whose specializations are types.
If the name found does not designate a namespace or a class, enumeration, or
dependent type, the program is ill-formed.

你能参考另一个问题或提供一点关于他们为什么这么说的信息,所以我们至少知道要考虑什么?嗯,这超出了我的头脑- + 1的有趣的问题,虽然我会期待答案:
9 Classes
Class-specifiers and elaborated-type-specifiers (7.1.5.3) are used to make class-names.
3.4.3/1 Qualified name lookup
...
If a :: scope resolution operator in a nested-name-specifier is not preceded
by a decltype-specifier, lookup of the name preceding that :: considers only 
namespaces, types, and templates whose specializations are types.
If the name found does not designate a namespace or a class, enumeration, or
dependent type, the program is ill-formed.