我已经切换了我的 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/