gpt4 book ai didi

c++ - boost::filesystem::path::imbue 使用默认 std::locale() 失败

转载 作者:行者123 更新时间:2023-11-28 00:12:30 24 4
gpt4 key购买 nike

boost::filesystem::path::imbue(std::locale());

效果不错。

下一个代码:

boost::filesystem::detail::utf8_codecvt_facet utf8_codecvt_facet;
boost::filesystem::path::imbue(std::locale(std::locale(), &utf8_codecvt_facet));

效果也不错。

下一个代码:

boost::filesystem::detail::utf8_codecvt_facet utf8_codecvt_facet;
boost::filesystem::path::imbue(std::locale(std::locale(), &utf8_codecvt_facet));
boost::filesystem::path::imbue(std::locale());

产生错误:

malloc: *** error for object 0x7fff5fbff6e8: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

OSX 10.10.5,Xcode,boost 1.57,开始 main()。

为什么?

最佳答案

当使用带面指针的构造函数时,创建的语言环境会获得面的所有权,因此将在其析构函数中将其删除。

在这里,您将指针传递给堆栈分配的方面。

关于c++ - boost::filesystem::path::imbue 使用默认 std::locale() 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32272959/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com