The actual result of name resolution in the class template is different from the c++ 03 standard

前端 未结 3 1627
太阳男子
太阳男子 2021-02-13 11:02

I test the code in the c++ standard ISO/IEC 14882-03 14.6.1/9 on Xcode 4.1 and Visual Studio 2008. The outputs of the two compiler are both different from the expected result of

3条回答
  •  -上瘾入骨i
    2021-02-13 11:27

    As noted in the first example, this is an instance of two-phase name lookup, which both GCC and Clang implement but MSVC does not. And in this case, both GCC and Clang are correct: it's actually the standard that is wrong, as noted in C++ core defect report #197. The C++11 standard contains a different example.

    This is one of the most common problems we see when porting code to Clang from either MSVC (which never implemented two-phase name lookup) or from GCC (which didn't implement two-phase name lookup uniformly until recently).

提交回复
热议问题