boost 相关问题

Boost是一系列旨在用于C ++的高质量库。 Boost是免费的,通常被认为是“第二标准库”。

C++ Boost SML 库

我正在尝试了解该库,但我对某些事件类型的高级概念感到困惑。我一直在这里阅读教程指南:Boost Experimental Documentation..它是

回答 1 投票 0

boost::ext:di通过工厂扩展创建带有shared_ptr参数的对象

这段代码运行良好: // g++ --版本 == 13.2.1 // g++ -O0 -g3 -std=gnu++20 -Wall -Wextra -Wpedantic -Werror -Wfatal-errors #包括 #包括...

回答 1 投票 0

Boost Python:公开 std::enums 列表

我有以下结构: 枚举类标签 { 二维码, 四月, 辣椒 } 结构选项 { std::list 标签; } 我想使用 boost python 在 Python 包中公开它。 这是我的

回答 1 投票 0

如何根据模板类型分配静态 constexpr 字段值

我想根据模板类型分配类的静态 constexpr 字段。 我找到了下面的解决方案,但我想这不是最好的解决方案,特别是如果有其他类型需要支持的话。也许...

回答 1 投票 0

Boost 内存映射文件:读写访问

我正在初始化 boostmapped_file_params,如下所示。 映射文件参数参数; param.path = _fileName.c_str(); param.flags =mapped_file::readwrite; int nGranularity =mapped_file::align...

回答 2 投票 0

可视化 boost sml 状态机

我第一次在 boost sml 中构建一个更大的状态机,并且需要一种方法来可视化(例如导出到 graphviz)整个状态机。知道如何才能做到这一点吗?有什么办法

回答 1 投票 0

为什么 boost::atomic 支持非平凡可复制对象?

boost::atomic 要求 T 可以轻松复制。但是为什么下面的 boost::atomic 代码有效呢? #包括 #包括 #包括 #包括...

回答 1 投票 0

[Boost::ext].SML:有没有办法存储回调以便稍后处理事件?

我来自 Boost MSM,现在正在尝试使用 SML 1.1.3 实现相同的状态机。 使用 SML,我无法访问状态机本身,并且被迫使用注入的依赖项...

回答 1 投票 0

boost::asio 的分段错误,带有deadline_timer 的异步udp 服务器

我在使用 boost::asio 库的服务器程序时遇到问题。 Server 类非常类似于 boost asio 教程“异步 udp-server”中介绍的类 班级...

回答 1 投票 0

GMock / 虚拟函数 / Boost MSM 如何正确组合?

我需要你的帮助。下列: 类 X 定义了组成命令的方法。这些命令被发送到 UART 设备。 X 类必须是静态的。类 X 的方法必须在状态下调用

回答 1 投票 0

C++ 的 YAML 序列化库?

YAML 似乎是一种很好的格式,用于以人类可读的形式配置文件和数据绑定持久对象...... 是否有处理 YAML 的 C++ 库? Boost::连载有计划吗...

回答 3 投票 0

在 QT Creator 中构建时无法更改 Boost 的版本

我正在尝试使用此处的说明构建 Fritzing: https://github.com/fritzing/fritzing-app/wiki/1.-Building-Fritzing 这里: https://siytek.com/build-fritzing-windows/ 和这里: https://www.yo...

回答 1 投票 0

Boost ASIO:通知所有待处理的任务

假设有 3 个任务注册到 ASIO io_context A、B 和 C。 A 现在可能正在运行,当它完成时,C 已经准备好运行,所以它确实可以运行,但即使完成时 B 还没有运行

回答 1 投票 0

从 boost::program_options 捕获异常

愚蠢的问题(但我在 boost.org 上没有找到任何内容):如何从 boost::program_options 捕获异常?调用 #包括 #包括 国际马...

回答 1 投票 0

boost handleAccept() 没有被调用

我正在尝试在端口 1234 上创建 TCP 服务器。下面的代码能够在端口 1234 上创建侦听器(通过 netstat -tln 确认)并且还从远程计算机建立连接(确认...

回答 1 投票 0

链接 CXX 可执行文件期间架构 x86_64 的未定义符号

我正在开发一个 javascript 运行时项目(它使用静态 v8 库来执行 javascript)。我为 x86 架构编译了 v8。我的Boost版本安装了 系统是1.68.0 这是一个

回答 1 投票 0

[Boost::ext].SML:如何在使用“_”(下划线)占位符时获取“on_entry<_>”和“on_exit<_>”中的“真实”事件

前提条件: 我使用编译器资源管理器 https://godbolt.org/ 运行下面截取的代码。 问题描述: 我尝试在使用通用事件(“_”下划线)时访问事件成员

回答 2 投票 0

boost-ext::sml 不会编译访问者示例

我正在尝试从源代码编译并尝试 boost::sml 中的示例。特别是访问者示例将无法编译,因此我的 sml 应用程序缺少一种直接的方法......

回答 1 投票 0

如何设置Boost RTree坐标系

这个例子,我编写了一种允许 rtree.query 工作的方法: 我想要与两个线段相交 使用 Point2d = 升压::几何::模型::点 在这个例子中,我编写了一种允许 rtree.query 工作的方法: 我想与两个线段相交 using Point2d = boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>; using Segment2d = boost::geometry::model::segment<Point2d>; using SegmentRtree = boost::geometry::index::rtree<Segment2d, boost::geometry::index::rstar<16>>; for (int point_index = 0; point_index + 1 < segment.line_segment().point_size(); point_index++) { const Segment2d segment_in_range = { {segment.line_segment().point()[point_index].x(), segment.line_segment().point()[point_index].y()}, {segment.line_segment().point()[point_index + 1].x(), segment.line_segment().point()[point_index + 1].y()}}; uncrossable_segments_in_range.insert(segment_in_range); 我遇到的一些错误: /home/xx/xx/xx/xx/xx/xx/xx/xx.cc:220:66: required from here /home/xx/xx/xx/build_x86/_deps/boost-src/include/boost/geometry/strategies/index/services.hpp:31:5: error: static assertion failed: Not implemented for this coordinate system. 31 | BOOST_GEOMETRY_STATIC_ASSERT_FALSE( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 看起来 100% 像是您忘记包含一些标头。 该消息没有说明“您没有指定坐标系”(您指定了,它在您的点类型中)。它说“尚未找到该组合的专业化(对于该算法/策略/特征等...)”。 代码取证 但是,您没有显示包含内容,所以我们无法判断。另外,您 do 显示的代码引用了许多与 Boost Geometry 无关的专有类型(point_size()、line_segment()、point()[] 似乎都与 Boost Geometry 无关)。 甚至.x()和.y()与您定义的点类型相矛盾。 point<> 没有有这些成员。不过,boost::geometry::model::d2::point_xy<>确实如此。 所以,我能做的最好的事情就是编写大量(!!!)代码来让你的代码编译: 住在Coliru #include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/segment.hpp> namespace bg = boost::geometry; namespace bgm = bg::model; namespace bgi = bg::index; // using Point2d = bgm::point<double, 2, bg::cs::cartesian>; using Point2d = bgm::d2::point_xy<double, bg::cs::cartesian>; using Segment2d = bgm::segment<Point2d>; using SegmentRtree = bgi::rtree<Segment2d, bgi::rstar<16>>; /////// stubs to make the code look like the question code... struct { auto const& line_segment() { return ls_; } private: struct { Segment2d data_; size_t point_size() const { return 2; } struct proxy { Segment2d const& ref_; auto operator[](unsigned i) const { switch (i) { case 0: return ref_.first; case 1: return ref_.second; } throw std::range_error("i"); } }; proxy point() const { return {data_}; } } ls_; } segment; struct Comparer { using Point = Point2d; using Base = std::pair<Point2d, Point2d>; bool operator()(Point const& a, Point const& b) const { return std::tie(a.x(), a.y()) < std::tie(b.x(), b.y()); } bool operator()(Base const& a, Base const& b) const { return operator()(a.first, b.first) || (bg::equals(a.first, b.first) && operator()(a.second, b.second)); } }; std::set<Segment2d, Comparer> uncrossable_segments_in_range; /////// end stubs int main() { for (unsigned point_index = 0; point_index + 1 < segment.line_segment().point_size(); point_index++) { Segment2d segment_in_range{{segment.line_segment().point()[point_index].x(), segment.line_segment().point()[point_index].y()}, {segment.line_segment().point()[point_index + 1].x(), segment.line_segment().point()[point_index + 1].y()}}; uncrossable_segments_in_range.insert(segment_in_range); } } 这会让你的循环更具可读性: auto& ls = segment.line_segment(); for (unsigned i = 0; i + 1 < ls.point_size(); i++) { auto&& p = ls.point(); uncrossable_segments_in_range.emplace(Point2d{p[i].x(), p[i].y()}, Point2d{p[i + 1].x(), p[i + 1].y()}); } 现在,这看起来像是难以想象的(糟糕的)代码量。另外,它对 rtree 什么都没有,这应该是你的问题? 脑波 - 更合理的代码 我灵机一动。也许 uncrossable_segments_in_range 应该是你的 rtree?整个循环是从[一些不相关的数据结构]构建rtree。我想象你会这样编写代码: 住在Coliru #include <boost/geometry.hpp> #include <boost/geometry/geometries/segment.hpp> namespace bg = boost::geometry; namespace bgm = bg::model; namespace bgi = bg::index; using Point2d = bgm::point<double, 2, bg::cs::cartesian>; using Segment2d = bgm::segment<Point2d>; using LineString = bgm::linestring<Point2d>; using SegmentRtree = bgi::rtree<Segment2d, bgi::rstar<16>>; int main() { SegmentRtree segments; LineString input; bg::read_wkt("LINESTRING(2 0, 5 3, 8 0, 4 -4, 11 -4, 11 5, 14 5)", input); for (auto it = bg::segments_begin(input); it != bg::segments_end(input); ++it) segments.insert({*it->first, *it->second}); for (auto& el : segments) std::cout << "in tree: " << bg::dsv(el) << std::endl; } 哪个打印 in tree: ((2, 0), (5, 3)) in tree: ((5, 3), (8, 0)) in tree: ((8, 0), (4, -4)) in tree: ((4, -4), (11, -4)) in tree: ((11, -4), (11, 5)) in tree: ((11, 5), (14, 5)) 总结 很可能,您只需添加可以从我的示例中交叉引用的包含内容之一。

回答 1 投票 0

weak_ptr 的性能损失是什么?

我目前正在为游戏设计一个对象结构,在我的例子中最自然的组织变成了一棵树。作为智能指针的忠实粉丝,我专门使用shared_ptr。然而,在这个

回答 3 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.