void to_stream(T const& value) { std::locale loc = m_Stream.getloc(); if (!std::has_facet< FacetT >(loc)) { // Add the formatting facet std::auto_ptr< FacetT > facet(new FacetT(m_Format.c_str())); m_Stream.imbue(std::locale(loc, facet.get())); facet.release(); loc = m_Stream.getloc(); } // Perform formatting std::ostreambuf_iterator< char_type > osb_it(m_Stream); std::use_facet< FacetT >(loc).put(osb_it, m_Stream, m_Stream.fill(), value); }