Subj : Re: Can C++ local static objects be made thread safe? To : comp.programming.threads From : Alexander Terekhov Date : Fri Feb 04 2005 10:08 am Marcin 'Qrczak' Kowalczyk wrote: > > Giancarlo Niccolai writes: > > >> Because it would change various instances of code written with no > >> threads in mind from unsafe to safe to use with threads. > > > > That is utterly impossible. > > It is possible. Consider this function: > > char32_t lookup_unicode_char_by_name(const string &name) { > static map database = > read_unicode_database_from_file(); > map::iterator it = database.find(name); You probably mean static const map database( read_unicode_database_from_file()); map::const_iterator it = database.find(name); > return it == database.end() ? it->second : (char32_t)-1; > } The thing is that not all local statics are immutable and/or need thread-safe init provided by implementation to begin with. regards, alexander. .