Has it std::string.nposever been valid? (Unlike the right one std::string::npos.)
std::string.npos
std::string::npos
I see this a lot in the old project I'm working on, and it does not compile with VS2010.
Is this some of the pre-standard days?
No, it std::string.nposhas never been valid, and no, this is not something from the pre-standard days.
I see other answers that mention that MSVC allowed this notation.
MSVC . , -t21. Windows GUI - , main. , Microsoft Herb Sutter ( , ), . , , , .
main
-, C , :: . :
::
class X { public: void f(); }; void X.f() // a dot! see D&E 2.3 { }
std . , std::string.npos Microsoft ( ?). , .
std
, , MSVC.
#include <iostream> struct A { static int a; }; int A::a; int main() { std::cout << A.a; }
MSVC9.0
1 C4832: '.' UDT 'A'
++ className.memberName ( object.staticMemberName).
className.memberName
object.staticMemberName
My common sense tells me that if MSVC realizes that this is not standard and gives a warning, we can disable this extension. Go to Project Propertied -> C/C++ -> Languageand set Disable Language Extensionsto Yes. Do you think something has changed? Of course not, the compiler still accepts illegal code with the same warning. I sometimes wonder what it actually does Disable Language Extensions...
Project Propertied -> C/C++ -> Language
Disable Language Extensions
Yes