尝试使用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:错误:使用已删除 函数'boost :: detail :: stored_edge_property :: self&amp; boost :: detail :: stored_edge_property :: operator =(boost :: detail :: stored_edge_property :: self&amp;&amp;)[with Vertex = long unsigned int,Property = boost :: no_property,boost :: detail :: stored_edge_property :: self = boost :: detail :: stored_edge_property]'
... /升压/升压/图形/细节/ adjacency_list.hpp:318: 错误:'boost :: detail :: stored_edge_property :: self&amp; boost :: detail :: stored_edge_property :: operator =(boost :: detail :: stored_edge_property :: self&amp;&amp;)[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:错误:基数 'boost :: detail :: stored_edge'没有动作 赋值运算符或普通拷贝赋值运算符
/ usr / include / c ++ / 4.6 / bits / stl_algobase.h:546:错误:使用已删除 函数'boost :: detail :: stored_edge_property :: self&amp; boost :: detail :: stored_edge_property :: operator =(boost :: detail :: stored_edge_property :: self&amp;&amp;)[with Vertex = long unsigned int,Property = boost :: no_property,boost :: detail :: stored_edge_property :: self = boost :: detail :: stored_edge_property]'
答案 0 :(得分:6)
对于版本1.55到1.56之间的C ++ 11 rvalue引用,似乎更新了stored_edge_property
(用于存储边缘属性的引擎盖类)的实现(你可以通过diff和它清楚地看到它) #39;文件)。看来他们忘了为它的基类stored_edge
提供一个移动赋值运算符(并且默认的运算符由于存在一个复制赋值运算符而被隐式禁用)。
这绝对是一个错误,应该报告给Boost。我记得他们在1.48版本的shared_ptr
附近犯了一个几乎完全相同的错误。我想人们总是不会从自己的错误中吸取教训。修复是微不足道的,但这确实应该在发布之前被捕获(在单元测试中看起来似乎是一个非常容易的错误)。请将您的调查结果报告给their bug tracker。
N.B。:我经常使用BGL,但我学会了不信任adjacency_list
实施,特别是在广泛查看之后。我现在使用我自己的实现(参见here),它切断了BGL带来的巨大实现的大量内容。