由于删除了函数,不同的boost版本导致boost/core/ref.hpp失败

Different boost version causing failure in boost/core/ref.hpp due to deleted function

本文关键字:boost 版本 core 失败 hpp ref 删除 于删除 函数      更新时间:2023-10-16

我已经切换了我的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的签名以接收指针