
David Manura wrote:
// Operation template<typename CharT> bool operator()( CharT Ch ) const { - return std::use_facet< std::ctype<CharT> >(m_Locale).is( m_Type, Ch ); + static const std::ctype<CharT> & data = std::use_facet< std::ctype<CharT> >(m_Locale); + return data.is( m_Type, Ch ); }
That is most definitely a bug waiting to pounce. m_Locale is specific to each instance. The static variable inside the member function is the same for all instances. The bug hits when somebody uses this functor with two different locales. The first object to invoke operator() will work fine - the second (and each subsequent) will mysteriously use the locale of the first. If you want to cache the ctype facet, do it as a class variable, perhaps in the constructor. Sebastian Redl