c++ - 由于删除的功能,不同的 boost 版本导致 boost/核心/ref.hpp 失败

标签 c++ boost

我已经切换了我的 boost 版本,我正在尝试重新编译我的代码,但我收到以下错误:

/boost/core/ref.hpp:179: error: deleted function ‘void boost::cref(const T&&) [with T = const char*]’

这是针对此特定行的:

    // find file prefix with matching system type in systemtype attribute
    pugi::xml_named_node_iterator xmniFilePrefix = std::find_if(xmnrFilePrefixes.begin(),xmnrFilePrefixes.end(),
                                    boost::bind(std::equal_to<std::string>(), 
                                                boost::bind(PUMLinux::Functions::ObtainAttributeValue, _1, boost::cref(PUMLinux::Configuration::SYSTEMTYPE.c_str())),
                                                c_strSystemType));

有人知道我可以做些什么来解决我正在使用的新 boost 的问题吗?

最佳答案

你不能这样做,boost 这样做是完全正确的。您正在将 cref() 用于临时,但 cref 只不过是指针周围的奇特包装。

因此,您正在尝试获取 c_str() 返回的临时对象的地址,这是不行不行的。

但是,由于它似乎是静态的、未更改的字符串 SYSTEMTYPE,您可以通过完全消除 boost::cref 来逃脱 - 传递 c_str() 的返回值直接地。您可能需要更改 ObtainAttributeValue 的签名以接收指针。

关于c++ - 由于删除的功能,不同的 boost 版本导致 boost/核心/ref.hpp 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32788168/

相关文章:

c++ - 从 xml 文件输入并使用 rapidxml 解析

c++ - 如何找到 vector 中的最大元素 (C++)?

.net - 是否有 .net 类似于 Boost 库?

c++ - 使用迭代器从 boost 多索引中删除项目时的一致性

c++ - Boost mpi x64 警告 "size_t to int"

c++ - boost::filesystem::path 和 std::string

c++ - OpenGL - 当我从一个单元格移动到另一个单元格时,相机移动有一个闩锁

C++ fatal error C1382 : the PCH file 'file' has been rebuilt since 'obj' was generated. 请重建此对象

c++ - OpenGL骨骼动画性能

c++ - 如何使用 C++11 或 Boost 获取正则表达式匹配的长度?