- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 vs-2017 中使用 Boost 1.70.0。使用 depth_first_search
时,我观察到访问者中的 finish_edge
函数在使用 msvc 编译器编译时未被调用。使用 gcc (8.3) 可以正确调用 finish_edge
函数
示例代码:
struct DfsVisitor : public boost::default_dfs_visitor
{
template <class Graph>
void
finish_edge(typename Graph::edge_descriptor ed, const Graph& g)
{
std::cout << "Finish edge " << boost::source(ed, g) << "->" << boost::target(ed, g) << std::endl;
}
};
DfsVisitor dfs;
boost::depth_first_search(g, boost::visitor(dfs)); // g is graph, adjacency_list
最佳答案
Do you have a SSCCE that we can actually run to observe the behavior? That will save a lot of time
我刚刚这样做了:刚刚这样做了:repro Boost 1.60 on msvc
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/depth_first_search.hpp>
#include <iostream>
struct DfsVisitor : public boost::default_dfs_visitor {
template <class Graph> void finish_edge(typename Graph::edge_descriptor ed, const Graph &g) {
std::cout << "Finish edge " << boost::source(ed, g) << "->" << boost::target(ed, g) << std::endl;
}
};
int main() {
boost::adjacency_list<> g(4);
add_edge(0,1,g);
add_edge(1,2,g);
add_edge(2,3,g);
DfsVisitor dfs;
boost::depth_first_search(g, boost::visitor(dfs));
std::cout << "Done\n";
}
只打印:
Done
为了比较,
Boost 1.70 在 GCC 9.1 上打印正确的输出:( https://godbolt.org/z/PMbEFL )
Finish edge 2->3
Finish edge 1->2
Finish edge 0->1
很明显,它与 boost 版本的关系比与编译器的关系更大。 Godbolt 不会比 Boost 1.64 更早(仍然可以:https://godbolt.org/z/Ld8-8d)但 wandbox 可以:
检查 release notes for Boost 1.62.0似乎没有提到什么,但使用 github 历史确实发现了:
$ git clone https://github.com/boostorg/graph
$ cd graph
$ git log --oneline --graph --left-right --cherry-pick boost-1.61.0...boost-1.62.0 | grep -i finish
> a14f8df8 Fixed bug 10231 partly: If finish_edge was called, then now correctly. (#16)
> d6b7a717 Add finish_edge test case from Alex Lauser.
> 6a2d45ae Condition TTI finish_edge on supported compilers.
> 0e1414f4 Fix type traits so finish_edge is called when defined.
关于c++ - boost 图形库,depth_first_search 不在 msvc 中调用 finish_edge,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56746453/
我有两个单独编译的DLL,一个是从Visual Studio2008编译的,另一个是从MATLAB编译的MEX文件。这两个DLL都包含一个头文件。当我获取一个DLL中的结构sizeof()时,它返回4
一位同事更喜欢尤达的条件:。这在团队中是一种有争议的风格,并且提出的一个论点是,如果(x=0),编译器可以一致地发出警告来检测错误模式。。然而,msvc似乎没有检测到类(https://godbolt
while (getline(stream, thisword, ' ') != 0) {... 我可以在 MSVC 2012 下编译这一行。通过传递一个“SPC”字符作为字符串分隔符,它应该测试输入
我使用较早版本的 Cocos2dx 编写游戏并使用 VS 2013 对其进行编译。请注意,我使用的是 CMake 和 Qt Creator 以及两个编译器版本。当 Cocos2dx v3.12 出来时
我正在尝试在 Windows 10 64 位下的 Python 3.8.3 上安装 chatterbot 包并遇到一个奇怪的错误,我怀疑它一定与某些目录或 PATH 设置有关,我希望这是一个简单的修复
知乎Where and why do we have to put the template and typename keywords , 我很惊讶地得知 MSVC accepts以下代码: str
在摆弄复制省略时,我遇到了这种奇怪的行为: class Obj { public: Obj() = default; Obj(Obj&&) = delete; Obj(const Obj
以下代码使用 gcc 和 clang(以及许多其他 C++11 编译器)进行编译 #include typedef int datatype; template struct to_datatyp
我已经阅读了很多帖子,但我不明白如何在命令行中使用 MSVC 在 Windows 上创建一个简单的动态库。我正在做的是: 1º) 编写 DLL 代码 动态.h #pragma once __decls
我有以下代码无法与MSVC一起编译。使用gcc,clang和icc可以正常编译。我想这是个错误,对不对? 您有/知道一些解决方法吗? #include struct A { template
我已经阅读了很多帖子,但我不明白如何在命令行中使用 MSVC 在 Windows 上创建一个简单的动态库。我正在做的是: 1º) 编写 DLL 代码 动态.h #pragma once __decls
我有一个简单的 C++ 代码,我尝试使用 Visual Studio 2019 进行编译: #include #include int main() { std::cout << "Hel
有没有办法告诉MSVC编译器在短时间内不要修改某个寄存器?就像在一个小循环中,告诉它不要使用 ebx 寄存器(它可以使用任何其他寄存器)。在这种情况下,压入和弹出寄存器不起作用,因为在我将其弹出后,M
Borland C 有伪寄存器 _AX、_BX、_FLAGS 等,可以在“C”代码中使用它们将寄存器保存到临时变量。 是否有任何 MSVC 等效项?我尝试了@AX、@BX等,但编译器(MSVC1.5)
美好的一天, 我在 C++ 中尝试新事物,我发现 Visual Studio 中的调试和发布配置给我不同的结果。 #include #include #include #include #in
我想我在 MSVC 的编译器(MSVC Ultimate 2012 版本 11.0.61030.00 更新 4)中发现了一个错误。 #include "stdafx.h" class Base { p
我正在使用 Haxe 的 HXCPP 生成 C++ 代码并使用 Microsoft Visual Studio 2010 Express Edition 对其进行编译。我正在关注 this指南,它会要
我正在使用 Microsoft Visual Studio 2008 (C++)。我有一个要在 Debug模式下构建的解决方案。我引用了一些第三方库(例如 MyGUI)。在调试构建结束时,链接器给出了
老计算机程序员遇到新问题:-) 我正在将一个 CMake 文件项目移至 Visual Studio,并且该 CMake 项目中有数百个包含路径。 我当然可以一劳永逸地修补它们,但这会经常发生在不同的机
我有下一个功能: namespace TEST { class TEST { int a; int b; }; } namespace UNION_TE
我是一名优秀的程序员,十分优秀!