Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why members of std::basic_string are public in VS2010?

Tags:

#include <iostream>
#include <string>
int main()
{
    std::string s;
    s._Mysize = 7;  // Well compiled !!!
    std::cout << s.size() << '\n'; // prints 7   !!!

}

Why non-static members of the std::basic_string are public in VS2010 ?

Is this bug ? If yes, how about of next version of visual studio's ( vs2012 and vs2013) ?

EDIT: I just test other containers, and ... interesting vector and unique_ptr's non-static members are public, also.

std::vector<char> v;
v._Myfirst = (char*)2; // Well Compiled.


std::unique_ptr< int > u;

u._Myptr = 0; // well compiled.

Q: Is here any reason or advantage of using public data members ?