使用boost.graph 1.56.0和g ++ 4.6.4编译错误

rad*_*man 7 c++ gcc boost compiler-errors c++11

在尝试使用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;
}
Run Code Online (Sandbox Code Playgroud)

从我的IDE复制的错误

/usr/include/c++/4.6/bits/vector.tcc:319:错误:使用已删除的函数'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:错误:'boost :: detail :: stored_edge_property :: self&boost :: detail :: stored_edge_property :: operator =(boost :: detail :: stored_edge_property :: self &&)[使用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:错误:base'boost :: detail :: stored_edge'没有移动赋值运算符或普通复制赋值运算符

/usr/include/c++/4.6/bits/stl_algobase.h:546:错误:使用已删除的函数'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]'

Mik*_*son 6

看来,对于stored_edge_property版本1.55到1.56之间的C++ 11 rvalue引用,更新了(一个用于存储边缘属性的引擎盖下类)的实现(你可以通过对文件进行差异来清楚地看到它).看起来他们忘了为它的基类提供一个移动赋值运算符stored_edge(并且默认的运算符由于存在复制赋值运算符而被隐式禁用).

这肯定是一个错误,应该报告给Boost.我记得他们shared_ptr在1.48版本周围犯了几乎相同的错误.我想人们并不总是从自己的错误中吸取教训.修复是微不足道的,但这确实应该在发布之前被捕获(在单元测试中看起来似乎是一个非常容易的错误).请将您的发现报告给他们的错误跟踪器.

注意:我经常使用BGL,但是我学会了不信任它们的adjacency_list实现,特别是在广泛浏览之后.我现在使用我自己的实现(见这里),它切断了BGL所带来的巨大实现的大量内容.