Ownership/delete'ing the facet in a locale (std::locale)
问题 I wrote the following function to get a date/time string using boost.date_time. namespace bpt = boost::posix_time; string get_date_time_string(bpt::ptime time) { bpt::time_facet * facet(new bpt::time_facet); facet->format("%Y%m%d%H%M%S"); stringstream return_value; return_value.imbue(std::locale(std::locale::classic(), facet)); return_value << time; return return_value.str(); } I had a quick question about the ownership/ delete 'ing of the facet object. std::locale's constructor is not