std::vector< std::string> a; // ...fill it // WRONG !!! get_log().ts() << "Here are the strings from array a:\n"; // ... note: temporary returned by get_log() // has been destructed here std::vector< std::string>::const_iterator first = a.begin(), last = a.end(); while ( first != last) { get_log().ts() << *first++ << " "; // ... note: temporary returned by get_log() // has been destructed here } The above should become: std::vector< std::string> a; // ...fill it thread_safe_log log = get_log(); log.ts() << "Here are the strings from array a:\n"; std::vector< std::string>::const_iterator first = a.begin(), last = a.end(); while ( first != last) log.ts() << *first++ << " "; log << std::endl; |