gpt4 book ai didi

c++ - boost.graph 1.56.0 和 g++ 4.6.4 编译错误

转载 作者:可可西里 更新时间:2023-11-01 18:35:43 25 4
gpt4 key购买 nike

在尝试使用 Boost.Graph 时遇到了一些严重的编译错误。该错误是回归,因为它在编译 1.55.0 时不存在。我已经挖了一点但无法修复它,有人知道这里出了什么问题吗?

注意事项:使用 -std=c++0x 编译标志

将产生错误的代码。

#include "boost/graph/adjacency_list.hpp"

int main(int argc, char** argv)
{
using boost::adjacency_list;
using boost::vecS;
using boost::directedS;
typedef adjacency_list<vecS, vecS, directedS, boost::default_color_type> Graph;

std::vector< std::pair<int, int> > testVec;
auto graph = Graph( begin(testVec), end(testVec), testVec.size());

return 0;
}

从我的 IDE 复制出来的错误

/usr/include/c++/4.6/bits/vector.tcc:319: error: use of deleted function ‘boost::detail::stored_edge_property::self& boost::detail::stored_edge_property::operator=(boost::detail::stored_edge_property::self&&) [with Vertex = long unsigned int, Property = boost::no_property, boost::detail::stored_edge_property::self = boost::detail::stored_edge_property]’

.../boost/boost/graph/detail/adjacency_list.hpp:318: error: ‘boost::detail::stored_edge_property::self& boost::detail::stored_edge_property::operator=(boost::detail::stored_edge_property::self&&) [with Vertex = long unsigned int, Property = boost::no_property, boost::detail::stored_edge_property::self = boost::detail::stored_edge_property]’ is implicitly deleted because the default definition would be ill-formed:

.../boost/boost/graph/detail/adjacency_list.hpp:318: error: base ‘boost::detail::stored_edge’ does not have a move assignment operator or trivial copy assignment operator

/usr/include/c++/4.6/bits/stl_algobase.h:546: error: use of deleted function ‘boost::detail::stored_edge_property::self& boost::detail::stored_edge_property::operator=(boost::detail::stored_edge_property::self&&) [with Vertex = long unsigned int, Property = boost::no_property, boost::detail::stored_edge_property::self = boost::detail::stored_edge_property]’

最佳答案

stored_edge_property(一个用于存储边属​​性的底层类)的实现似乎已针对版本 1.55 到 1.56 之间的 C++11 右值引用进行了更新(您可以看到它通过区分文件很明显)。看来他们忘记为其基类 stored_edge 提供移动赋值运算符(默认值因复制赋值运算符的存在而被隐式禁用)。

这绝对是一个错误,应该报告给 Boost。我记得他们在 1.48 版本的 shared_ptr 上犯了一个几乎相同的错误。我想人们并不总是从自己的错误中吸取教训。修复是微不足道的,但这确实应该在发布之前被发现(这似乎是一个非常容易在单元测试中发现的错误)。请将您的发现报告给their bug tracker .

N.B.:我经常使用 BGL,但我学会了不信任他们的 adjacency_list 实现,尤其是在广泛查看之后。我现在使用我自己的实现(请参阅 here),它削减了 BGL 携带的巨大实现的大量脂肪。

关于c++ - boost.graph 1.56.0 和 g++ 4.6.4 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25395805/

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