我们是否应该释放为std :: locale分配的资源

编程入门 行业动态 更新时间:2024-10-09 11:18:53
本文介绍了我们是否应该释放为std :: locale分配的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 const std::locale fmt2(std::locale::classic(), new boost::gregorian::date_input_facet("%m/%d/%Y"));

在第二个参数中,我们使用new boost::gregorian::date_input_facet("%m/%d/%Y").

In the second parameter, we use new boost::gregorian::date_input_facet("%m/%d/%Y").

问题:我是否需要考虑释放分配的资源?

Question: Do I need to concern to release the allocated resource?

谢谢

推荐答案

否.需要实现来释放内存本身(除非您另外指定):

No. The implementation is required to deallocate the memory itself (unless you specify otherwise):

22.3.1.1.2类locale::facet

对于refs == 0,当销毁包含构面的最后一个语言环境对象时,实现将执行delete static_cast<locale::facet*>(f)(其中f是指向构面的指针);否则,执行delete static_cast<locale::facet*>(f)(其中f是指向构面的指针).对于refs == 1,实现永远不会破坏构面.

For refs == 0, the implementation performs delete static_cast<locale::facet*>(f) (where f is a pointer to the facet) when the last locale object containing the facet is destroyed; for refs == 1, the implementation never destroys the facet.

更多推荐

我们是否应该释放为std :: locale分配的资源

本文发布于:2023-11-24 16:55:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626060.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分配   资源   std   locale

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!