我想看一个示例,其中在整个后缀表达式的上下文中查找转换类型 ID

I'd like to see one example where the conversion-type-id is looked up in the context of the entire postfix-expression

在 [basic.lookup.classref]/7 (C++14) 中我们有(重点是我的):

If the id-expression is a conversion-function-id, its conversion-type-id is first looked up in the class of the object expression and the name, if found, is used. Otherwise it is looked up in the context of the entire postfix-expression. In each of these lookups, only names that denote types or templates whose specializations are types are considered.

我不明白上面 Otherwise 的必要性。因此,我想看一个示例,其中 conversion-type-id 在整个后缀表达式的上下文中查找。

某事like this:

struct C {
    operator int() { return 42; }
};

typedef int X;

int main() {
  C c;
  c.operator X();  // calls c.operator int();
}

显然,名称 X 未在 class C 中找到,但在使用它的表达式的上下文中找到。