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



在尝试使用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/位/向量。Tcc:319:错误:使用删除函数的详细boost:::: 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] '

…/提高/提高/图表/细节/adjacency_list.hpp: 318:错误:"详细boost:::: 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: base' boost::detail::stored_edge '没有移动赋值操作符或平凡复制赋值操作符

/usr/include/c++/4.6/bits/stl_algobase.h:546: error: use of deleted .h函数的详细boost:::: 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提供移动赋值操作符(默认的移动赋值操作符由于存在复制赋值操作符而被隐式禁用)。

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

注意:我经常使用BGL,但是我已经学会了不信任他们的adjacency_list实现,特别是在广泛地研究了它之后。我现在使用我自己的实现(见这里),它减少了BGL所带来的巨大实现的许多脂肪。

最新更新