Skip to content

Instantly share code, notes, and snippets.

@tredpath
Created November 21, 2016 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tredpath/5f762151c1595246cd21c4503bded3ea to your computer and use it in GitHub Desktop.
Save tredpath/5f762151c1595246cd21c4503bded3ea to your computer and use it in GitHub Desktop.
Testing vector type with Intel compiler
#include <vector>
#include <string>
using namespace std;
struct Foo
{
Foo() { }
Foo(const Foo& type)
{
//comment out this loop and it works
for (const auto& val : type.list) { }
}
~Foo()
{
//this fails if the vector has been iterated over
list.clear();
}
vector<string> list;
};
int main()
{
vector<Foo> vec;
//generate some test data
for (int i = 0; i < 20; i++)
{
Foo bar;
bar.list.push_back("Test1");
bar.list.push_back("Test2");
bar.list.push_back("Test3");
vec.push_back(bar);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment