gpt4 book ai didi

c++ - BGL 中的 slistS 发生了什么?

转载 作者:行者123 更新时间:2023-11-30 03:44:41 25 4
gpt4 key购买 nike

我正在使用 Boost 1.60 adjacency_list 并希望将 slistS 用于模板参数 OutEdgeList:

using Graph = boost::adjacency_list<
boost::slistS, boost::listS, boost::bidirectionalS
>;

这不会编译。看着adjacency_list.hpp在没有旧的 STL std::slist:

的情况下,似乎明确删除了这种类型
#if !defined BOOST_NO_SLIST
# ifdef BOOST_SLIST_HEADER
# include BOOST_SLIST_HEADER
# else
# include <slist>
# endif
#endif

#if !defined BOOST_NO_SLIST
struct slistS {};
#endif

boost::slistS 不能使用 std::forward_list 吗?如果没有,是否有任何计划将其包含在 BGL 的 future 版本中?

最佳答案

这在我看来是特定于 Clang/Libc++ 的,其中 <slist>不见了。它不是 c++ 标准的一部分。

用 GCC/libstdc++ 编译没问题(用 GCC 5.2 和 c++14 测试)。

所以我只使用 boost::container::slist :

Live On Coliru

#include <boost/container/slist.hpp>
#include <boost/graph/adjacency_list.hpp>

#ifdef BOOST_NO_SLIST
namespace boost {
struct slistS;

template <class ValueType> struct container_gen<slistS, ValueType> {
typedef boost::container::slist<ValueType> type;
};

template <> struct parallel_edge_traits<slistS> { typedef allow_parallel_edge_tag type; };
}
#endif

int main() {
using namespace boost;
adjacency_list<vecS, slistS> works_for_me;
}

关于c++ - BGL 中的 slistS 发生了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35312971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com