I am new to STL/C++11 programming, and am going through the motions to understand it.
And I am afraid I am stuck on what seems a trivial task, swapping string lists.
When I swap two lists of strings using the std::swap()
method, I get no errors, but the list class member function, swap(), gives me an access violation:
#include<iostream>
#include<list>
#include<string>
using namespace std;
int main()
{
list<string> superheroes {"Spidey", "Supes", "Bats"};
list<string> supervillains {"Goblin", "Luthor", "Joker"};
std::swap(superheroes, supervillains); //swaps fine
superheroes.swap(supervillains); //access violation
return 0;
}
I am using Visual Studio Pro 2013.