I have the following code -:
int main()
{
set<string> s;
s.insert( "asas" );
s.insert( "abab" );
for ( auto item : s )
{
cout << item << "\n";
reverse( item.begin(), item.end() );
}
cout << "\n";
for ( auto item : s )
{
cout << item << "\n";
}
}
Output -:
abab
asas
abab
asas
The elements of the set are not being modified at all by the reverse()
function.
I suspect that the elements inside a set cannot be modified at all. But, if this is the case, why doesn't the compiler give an error in the first place itself ?
I am using TDM-GCC 4.9.2 with -std=c++14
flag on Windows 7.