I am trying the new features of c++11 and I found an issue. This is my code:
#include <iostream>
#include <list>
#include <string>
using namespace std;
class A {
public:
int f (list<string> a, list<string> b={})
{
cout << a.size() << endl;
cout << b.size() << endl; // This line!!!
return 0;
}
};
int main ()
{
A a;
list<string> l{"hello","world"};
a.f(l);
return 0;
}
the execution stuck at "This line!!!" line. I continue debugging and it looks like the problem is here.
/** Returns the number of elements in the %list. */
size_type
size() const _GLIBCXX_NOEXCEPT
{ return std::distance(begin(), end()); }
I compile my program in this way:
g++ -std=c++11 -ggdb3 -fPIC -o test TestlistInit.cpp
I am using this version of g++:
g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2
thanks in advance!!!