Hello,
Anyone has an idea why this code crashes:
// snippet on
#include <list>
#include <string>
#include <iostream>
#include
struct null_deleter { void operator()(void const *) const {} };
int main()
{
std::liststd::ostream > l;
boost::shared_ptrstd::ostream p(&std::cout, null_deleter());
*p << "on the shared pointer" << std::endl;
l.push_back(p);
std::liststd::ostream >::iterator it =
l.begin();
std::cout << "before loop" << std::endl;
while (it++ != l.end())
{
boost::shared_ptrstd::ostream p2 = *it;
*p2 << "test" << std::endl; // crash here
}
return 0;
}
// snippet off
// output on
on the shared pointer
before loop
segmentation fault
// output off
It crashes on:
std::ostream::sentry::sentry () from /usr/lib/libstdc++.so.6
Thanks.