相关疑难解决方法(0)

拥有/删除区域设置中的构面(std :: locale)

我编写了以下函数来使用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();
}
Run Code Online (Sandbox Code Playgroud)

我对所有权/一个简单的问题delete了的"ING facet对象.std :: locale的构造函数没有明确的所有权/ delete' facet.尝试使用shared_ptr-wrapped和堆栈分配版本facet- 两者都导致了seg-fault.此外,通过valgrind运行上述函数并没有显示任何泄漏(这可能意味着语言环境或流正在delete处理),但我只是想清楚我在这里做正确的事情.谢谢.

c++ boost locale facet boost-date-time

16
推荐指数
1
解决办法
2083
查看次数

标签 统计

boost ×1

boost-date-time ×1

c++ ×1

facet ×1

locale ×1