Boost logo

Boost :

From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2007-11-10 08:32:28


Beman Dawes wrote:
> std::locale global_loc = std::locale();
> fs::detail::utf8_codecvt_facet utf8_facet;
> std::locale loc( global_loc, &utf8_facet );
>
Eep, don't do that!

Facets are reference-counted. The locale adds a reference when you add
the facet, and takes it away when it is destructed. When the count drops
to zero, it tries to delete the facet.

Either allocate the facet with new and pass it to the locale, or pass 1
to its constructor so that the reference counter is initialized at 1 and
never drops to zero.

Sebastian Redl


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk