Boost子图复制构造函数不适用于Qt 5.0.2和MinGW
Boost Subgraph Copy Constructor not working with Qt 5.0.2 and MinGW
我的项目使用的是Qt 4.8和minGW编译器以及boost 1.46.0,但现在我已经改用Qt 5.0.2和minGW编译以及boost 1.55.0,但子图的复制构造函数工作不好。它不是将顶点添加到子图(如果执行调试,则在顶点列表中显示0个项目)。
typedef boost::adjacency_list< boost::listS,
boost::vecS,
boost::bidirectionalS,
boost::property<boost::vertex_index_t, int ,
property<vertex_position_t, point, VertexProperties> > ,
boost::property<boost::edge_index_t,int , EdgeProperties>,
boost::property<graph_custom_prop_t,GraphProperties> >
Graph;
typedef boost::subgraph< Graph > SubGraph;
我正在gMainGraph中输入,需要将其复制到m_gMainGraph
SubGraph* m_gMainGraph;
m_gMainGraph = new SubGraph(gMainGraph);
正在创建子图,但子图中的顶点和边没有创建,而是仅添加到最顶部的父图中。在上面的代码中,gMainGraph没有被深度复制到m_gMainGraph。
这是解决这个问题的一些方法,因为在boost 1_55_0中没有实现子图复制构造函数来执行深度复制。我尝试过更新boost子图副本构造函数。只需在boost的子图.hpp文件中使用以下代码。您需要对1.52.0中的一些代码进行注释,并使用以下更改。
// copy constructor
/*Updated the copy constructor to work properly
As it's working in 1.46.0 and not in 1.52.0, In 1.52.0, the subgraph constructor is not itrating the child of child subgraphs
So only the direct children of main subgraph was getting copied*/
subgraph(const subgraph& x)
: m_graph(x.m_graph), m_parent(x.m_parent), m_edge_counter(x.m_edge_counter) //Added m_graph(x.m_graph)
, m_global_vertex(x.m_global_vertex), m_global_edge(x.m_global_edge)
{
// This loop belongs to 1.46.0
for(typename ChildrenList::const_iterator i = x.m_children.begin();
i != x.m_children.end(); ++i)
{
m_children.push_back(new subgraph<Graph>( **i ));
}
/* 1.52.0 code*/
// if(x.is_root())
// {
// m_graph = x.m_graph;
// }
// // Do a deep copy (recursive).
// // Only the root graph is copied, the subgraphs contain
// // only references to the global vertices they own.
// typename subgraph<Graph>::children_iterator i,i_end;
// boost::tie(i,i_end) = x.children();
// for(; i != i_end; ++i)
// {
// subgraph<Graph> child = this->create_subgraph();
// child = *i;
// vertex_iterator vi,vi_end;
// boost::tie(vi,vi_end) = vertices(*i);
// for (;vi!=vi_end;++vi)
// {
// add_vertex(*vi,child);
// }
// }
}
相关文章:
- 如何使用MinGW编译器和SSL支持静态编译Qt
- 如何在VS2017中构建Mingw Qt项目
- 如何使用MINGW-W64通过链接时间优化构建QT
- 使用由 Mingw 5.3 编译的 boost ASIO 库使用 QT 时出错
- 我如何在使用Mingw 32编译的QT框架中使用与MSVC 14.0编译的库
- 使用MinGW的Qt Creator中的代码覆盖率
- 使用MinGW 6.3.0时,Qt 5.7.0的静态构建无法完成
- 用GCC 4.6.2 C QT设置堆栈大小,Mingw,Vista
- 交叉编译Qt(Linux/MINGW -> Windows):各种未定义的引用
- `fopen'和qt(mingw)的错误
- 预编译HEADERS在使用Qt Creator/qmake/MinGw的调试构建中不起作用
- 建筑Qt静态,找不到MinGW
- Qt的MinGW,Code::Blocks的MinGW和MinGW本身有什么区别吗?
- 在qt(mingw)中启用c++1y
- Boost子图复制构造函数不适用于Qt 5.0.2和MinGW
- 参考off64_t,在mingw下Qt 5的静态编译失败
- 我应该在Qt创建者中更改什么,以便使用MinGW而不是microsoft编译器进行编译
- C++ Qt MingW 错误的重新定位0xc rdata 部分中的地址
- 如何为 Qt 而不是 MinGW 设置 Visual Studio 2012 RC 编译器
- 如何使 Mingw 编译器与 Qt 4.8.5 兼容