boost 相关问题

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

Boost asio 串口在 async_read 上提前完成

我有一个在 Windows 系统上包装 boost::asio::serial_port 的类。我用它来启动对提供的缓冲区的异步读取。 在大多数情况下,当队列中有数据时,它效果很好...

回答 1 投票 0

Boost 测试:如何使用输入和输出参数化测试?

在 Boost.Test 中,我想测试不同值的函数,每个值都与预期结果相关联。 像这样的东西(我知道,测试很愚蠢): void SquareTest(int ExpectedResult, int in...

回答 1 投票 0

使用 Bazel 通过 Boost.asio 构建应用程序

我正在尝试使用 Bazel 使用 boost.asio 构建简单的代码: 主程序 #包括 #包括 升压::asio::io_service io_service; 无效listenUDP(嘘...

回答 1 投票 0

Boost 多精度库

Boost 多精度库可能实现最高价值 boost 多精度可以处理像 googolplex 这样大的值吗,就像 boost 多精度 cpp dec float 库一样? 那么有人可以...

回答 1 投票 0

将 boost 编译为通用库(Intel 和 Apple Silicon 架构)

我正在尝试在 MacOS 上将 boost 库构建为 dylib。我需要为 Intel 架构和即将推出的 Apple Silicon (arm64) 架构构建它。 我下载了 boost 并运行了以下命令

回答 9 投票 0

假设安装了GCC和G++如何编译使用boost库的文件? (穿线)

所以我对linux很陌生。我已经设置了linux Debian,并且安装了gcc。我有一个使用 boost 线程库的简单 C++ 文件。让我们将该文件称为 example.cpp,我们有它的正确路径....

回答 1 投票 0

在 C++ 中包含目录时指定完整路径

在C++中,我正在搞乱boost库,并且我有一个“boost\”目录,其中包含所有boost .hpp文件和目录,以及我的编译器的包含文件夹中的“MinGW\include oost\”。现在...

回答 1 投票 0

使用自定义属性提升 BOOST_LOG_SEV

我需要一个 Boost 记录器,它使用以下参数记录到控制台(然后记录到文件): “[%TimeStamp%] [%Severity%] [%File%(%Line%)] %Message%”。 我已阅读 Boost.Log v2 文档并得到...

回答 1 投票 0

如何将异构键类型与 boost::unordered_flat_map 一起使用

Boost unordered_flat_map 非常好,它比 std::unordered_map 快得多。我尝试将它与异构密钥类型一起使用: boost::unordered::unordered_flat_map my_m...

回答 2 投票 0

如何在 boost::unordered_flat_map 中使用异构类型

Boost unordered_flat_map 非常好,它比 std::unordered_map 快得多。我正在尝试将它与异构类型一起使用: boost::unordered::unordered_flat_map my_map; ...

回答 2 投票 0

memcpy 相当于在复制时跳过 x 字节(不仅仅是初始 x 字节)?

我正在寻找一个类似于 memcpy 的现有函数,它可以被告知复制 x 字节,然后跳过 y 字节,重复直到复制了指定的数量。 想象一个带有数据的缓冲区:AABAA...

回答 3 投票 0

如何在 boost::unordered_flap_map 中使用异构类型

Boot unordered_flat_map 非常好,它比 std::unordered_map 快得多。我正在尝试将它与异构类型一起使用: boost::unordered::unordered_flat_map my_map; 我...

回答 1 投票 0

如何在主目录中创建文件夹?

我想创建一个目录路径=“$HOME/somedir”。 我尝试过使用 boost::filesystem::create_directory(path),但它失败了 - 显然该函数不会扩展系统变量。 怎么可以...

回答 2 投票 0

有没有办法将boost::json::serializer切换为美化输出?

使用 boost::json::serializer 如文档中的示例所示 - 快速查看以紧凑格式保存 json 树。 有没有办法指示序列化器输出人类可读的文件(即使用

回答 1 投票 0

将带有 2 个参数的类成员函数传递给 boost bind

Boost 绑定无法推导/替换模板参数: A级 { ... bool f(boost::shared_ptr>&, size_t); ... }; 一个我的A; 升压::绑定(&A:...

回答 1 投票 0

如何正确退出使用Boost Log的程序?

下面的示例程序工作正常,但 valgrind 显示,退出后仍然可以访问 6 个块中的 520 字节。 #包括 #包括 #包括 下面的示例程序工作正常,但是 valgrind 显示,退出后仍然可以访问 6 个块中的 520 字节。 #include <iostream> #include <string> #include <boost/log/common.hpp> #include <boost/log/sources/logger.hpp> #include <boost/log/utility/setup/file.hpp> #include <boost/phoenix/bind/bind_member_function.hpp> #include <boost/shared_ptr.hpp> namespace bl = boost::log; namespace bp = boost::phoenix; enum class MySeverityLevel { panic, alert, critical, error, warning, notice, info, debug }; BOOST_LOG_ATTRIBUTE_KEYWORD(Severity, "Severity", MySeverityLevel) BOOST_LOG_ATTRIBUTE_KEYWORD(Channel, "Channel", std::string) class Logger { public: Logger(const std::string& CH, const MySeverityLevel SEV): m_log(bl::keywords::channel = CH), m_channel(CH), m_severityMax(SEV) { m_sink = bl::add_file_log ( bl::keywords::file_name = CH + ".log", bl::keywords::filter = bp::bind(&Logger::filter, this, Channel.or_none(), Severity.or_none()) ); } ~Logger() { this->terminate(); } void terminate() { if (m_sink) { bl::core::get()->remove_sink(m_sink); m_sink->flush(); m_sink.reset(); } } void panic(const std::string& S) { BOOST_LOG_SEV(m_log, MySeverityLevel::panic) << S; } void debug(const std::string& S) { BOOST_LOG_SEV(m_log, MySeverityLevel::debug) << S; } private: using ChannelValue = bl::value_ref<std::string, tag::Channel>; using MySeverityLevelValue = bl::value_ref<MySeverityLevel, tag::Severity>; bool filter(const ChannelValue& CH, const MySeverityLevelValue& SEV) const { if (CH && SEV) { return (CH.get() == m_channel) && (SEV.get() <= m_severityMax); } else { return false; } } bl::sources::severity_channel_logger<MySeverityLevel, std::string> m_log; boost::shared_ptr<bl::sinks::sink> m_sink; const std::string m_channel; const MySeverityLevel m_severityMax; }; int main() { Logger lgA("A", MySeverityLevel::error); lgA.panic("A: Panic"); lgA.debug("A: Debug"); lgA.terminate(); } 这就是 valgrind 输出: hekto@ubuntu:~$ valgrind --leak-check=full --show-leak-kinds=all ./tc0013 ==48934== Memcheck, a memory error detector ==48934== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==48934== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info ==48934== Command: ./tc0013 ==48934== ==48934== ==48934== HEAP SUMMARY: ==48934== in use at exit: 520 bytes in 6 blocks ==48934== total heap usage: 83 allocs, 77 frees, 97,276 bytes allocated ==48934== ==48934== 8 bytes in 1 blocks are still reachable in loss record 1 of 6 ==48934== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==48934== by 0x4E98C61: boost::log::v2_mt_posix::sources::aux::get_severity_level() (in /usr/lib/x86_64-linux-gnu/libboost_log.so.1.65.1) ==48934== by 0x11723B: boost::log::v2_mt_posix::sources::aux::severity_level<MySeverityLevel>::set_value(MySeverityLevel) (severity_feature.hpp:135) ==48934== by 0x115E74: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_severity_logger<boost::log::v2_mt_posix::sources::basic_channel_logger<boost::log::v2_mt_posix::sources::basic_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MySeverityLevel>::open_record_unlocked<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (severity_feature.hpp:252) ==48934== by 0x114961: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_composite_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model, boost::log::v2_mt_posix::sources::features<boost::log::v2_mt_posix::sources::severity<MySeverityLevel>, boost::log::v2_mt_posix::sources::channel<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::open_record<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (basic_logger.hpp:575) ==48934== by 0x1135A5: Logger::panic(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (tc0013.cpp:81) ==48934== by 0x11097B: main (tc0013.cpp:120) ==48934== ==48934== 8 bytes in 1 blocks are still reachable in loss record 2 of 6 ==48934== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==48934== by 0x4E9EF69: boost::log::v2_mt_posix::aux::this_thread::get_id() (in /usr/lib/x86_64-linux-gnu/libboost_log.so.1.65.1) ==48934== by 0x4E8BB96: boost::log::v2_mt_posix::core::open_record(boost::log::v2_mt_posix::attribute_set const&) (in /usr/lib/x86_64-linux-gnu/libboost_log.so.1.65.1) ==48934== by 0x118DEA: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model>::open_record_unlocked<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (basic_logger.hpp:259) ==48934== by 0x11825B: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_channel_logger<boost::log::v2_mt_posix::sources::basic_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::open_record_with_channel_unlocked<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&, boost::parameter::void_) (channel_feature.hpp:195) ==48934== by 0x1172B2: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_channel_logger<boost::log::v2_mt_posix::sources::basic_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::open_record_unlocked<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (channel_feature.hpp:171) ==48934== by 0x115E8B: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_severity_logger<boost::log::v2_mt_posix::sources::basic_channel_logger<boost::log::v2_mt_posix::sources::basic_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MySeverityLevel>::open_record_unlocked<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (severity_feature.hpp:253) ==48934== by 0x114961: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_composite_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model, boost::log::v2_mt_posix::sources::features<boost::log::v2_mt_posix::sources::severity<MySeverityLevel>, boost::log::v2_mt_posix::sources::channel<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::open_record<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (basic_logger.hpp:575) ==48934== by 0x1135A5: Logger::panic(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (tc0013.cpp:81) ==48934== by 0x11097B: main (tc0013.cpp:120) ==48934== ==48934== 16 bytes in 1 blocks are still reachable in loss record 3 of 6 ==48934== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==48934== by 0x512A5BA: boost::detail::add_thread_exit_function(boost::detail::thread_exit_function_base*) (in /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1) ==48934== by 0x4E98C9A: boost::log::v2_mt_posix::sources::aux::get_severity_level() (in /usr/lib/x86_64-linux-gnu/libboost_log.so.1.65.1) ==48934== by 0x11723B: boost::log::v2_mt_posix::sources::aux::severity_level<MySeverityLevel>::set_value(MySeverityLevel) (severity_feature.hpp:135) ==48934== by 0x115E74: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_severity_logger<boost::log::v2_mt_posix::sources::basic_channel_logger<boost::log::v2_mt_posix::sources::basic_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MySeverityLevel>::open_record_unlocked<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (severity_feature.hpp:252) ==48934== by 0x114961: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_composite_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model, boost::log::v2_mt_posix::sources::features<boost::log::v2_mt_posix::sources::severity<MySeverityLevel>, boost::log::v2_mt_posix::sources::channel<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::open_record<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (basic_logger.hpp:575) ==48934== by 0x1135A5: Logger::panic(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (tc0013.cpp:81) ==48934== by 0x11097B: main (tc0013.cpp:120) ==48934== ==48934== 24 bytes in 1 blocks are still reachable in loss record 4 of 6 ==48934== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==48934== by 0x4E98C84: boost::log::v2_mt_posix::sources::aux::get_severity_level() (in /usr/lib/x86_64-linux-gnu/libboost_log.so.1.65.1) ==48934== by 0x11723B: boost::log::v2_mt_posix::sources::aux::severity_level<MySeverityLevel>::set_value(MySeverityLevel) (severity_feature.hpp:135) ==48934== by 0x115E74: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_severity_logger<boost::log::v2_mt_posix::sources::basic_channel_logger<boost::log::v2_mt_posix::sources::basic_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MySeverityLevel>::open_record_unlocked<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (severity_feature.hpp:252) ==48934== by 0x114961: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_composite_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model, boost::log::v2_mt_posix::sources::features<boost::log::v2_mt_posix::sources::severity<MySeverityLevel>, boost::log::v2_mt_posix::sources::channel<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::open_record<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (basic_logger.hpp:575) ==48934== by 0x1135A5: Logger::panic(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (tc0013.cpp:81) ==48934== by 0x11097B: main (tc0013.cpp:120) ==48934== ==48934== 24 bytes in 1 blocks are still reachable in loss record 5 of 6 ==48934== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==48934== by 0x512A1BC: boost::detail::make_external_thread_data() (in /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1) ==48934== by 0x512A5AD: boost::detail::add_thread_exit_function(boost::detail::thread_exit_function_base*) (in /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1) ==48934== by 0x4E98C9A: boost::log::v2_mt_posix::sources::aux::get_severity_level() (in /usr/lib/x86_64-linux-gnu/libboost_log.so.1.65.1) ==48934== by 0x11723B: boost::log::v2_mt_posix::sources::aux::severity_level<MySeverityLevel>::set_value(MySeverityLevel) (severity_feature.hpp:135) ==48934== by 0x115E74: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_severity_logger<boost::log::v2_mt_posix::sources::basic_channel_logger<boost::log::v2_mt_posix::sources::basic_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MySeverityLevel>::open_record_unlocked<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (severity_feature.hpp:252) ==48934== by 0x114961: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_composite_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model, boost::log::v2_mt_posix::sources::features<boost::log::v2_mt_posix::sources::severity<MySeverityLevel>, boost::log::v2_mt_posix::sources::channel<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::open_record<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (basic_logger.hpp:575) ==48934== by 0x1135A5: Logger::panic(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (tc0013.cpp:81) ==48934== by 0x11097B: main (tc0013.cpp:120) ==48934== ==48934== 440 bytes in 1 blocks are still reachable in loss record 6 of 6 ==48934== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==48934== by 0x512A03D: boost::detail::make_external_thread_data() (in /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1) ==48934== by 0x512A5AD: boost::detail::add_thread_exit_function(boost::detail::thread_exit_function_base*) (in /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1) ==48934== by 0x4E98C9A: boost::log::v2_mt_posix::sources::aux::get_severity_level() (in /usr/lib/x86_64-linux-gnu/libboost_log.so.1.65.1) ==48934== by 0x11723B: boost::log::v2_mt_posix::sources::aux::severity_level<MySeverityLevel>::set_value(MySeverityLevel) (severity_feature.hpp:135) ==48934== by 0x115E74: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_severity_logger<boost::log::v2_mt_posix::sources::basic_channel_logger<boost::log::v2_mt_posix::sources::basic_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MySeverityLevel>::open_record_unlocked<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (severity_feature.hpp:252) ==48934== by 0x114961: boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_composite_logger<char, boost::log::v2_mt_posix::sources::severity_channel_logger<MySeverityLevel, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::log::v2_mt_posix::sources::single_thread_model, boost::log::v2_mt_posix::sources::features<boost::log::v2_mt_posix::sources::severity<MySeverityLevel>, boost::log::v2_mt_posix::sources::channel<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::open_record<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, MySeverityLevel const> const&) (basic_logger.hpp:575) ==48934== by 0x1135A5: Logger::panic(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (tc0013.cpp:81) ==48934== by 0x11097B: main (tc0013.cpp:120) ==48934== ==48934== LEAK SUMMARY: ==48934== definitely lost: 0 bytes in 0 blocks ==48934== indirectly lost: 0 bytes in 0 blocks ==48934== possibly lost: 0 bytes in 0 blocks ==48934== still reachable: 520 bytes in 6 blocks ==48934== suppressed: 0 bytes in 0 blocks ==48934== ==48934== For counts of detected and suppressed errors, rerun with: -v ==48934== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) 在我的实际应用程序中,Logger类位于库中,这就是为什么我需要正确终止它(终止由systemctl执行)。但是,在退出应用程序期间,我仍然在 syslog 中看到异常: terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::log::v2_mt_posix::system_error> >' 我认为找到一种方法在退出后摆脱这些“6个块中的520字节”将帮助我清楚地终止我的应用程序。 如何正确编写 terminate 函数(见上文) - 以便 不 使 Boost Log 内部的任何内容都可访问? 操作系统:Ubuntu 18.04.1 LTS 编译器:g++ 7.3.0 提升:1.65.1 Valgrind:3.13.0 tl;dr; boost.log 注定要失败,使用其他东西...... 这些调用堆栈中的特殊细节是重复调用boost::detail::add_thread_exit_function,它是boost::this_thread::at_thread_exit的实现,显然用于在线程即将结束时执行一些清理操作。然而,此函数不能与系统特定的线程结束 API 和函数(例如 exit)一起使用。如文档中所述: 特别是,从main()返回相当于调用exit(),因此不会调用任何用at_thread_exit()注册的函数 因此 boost.log 在从主线程调用时不会执行任何清理。此外,(除了其他丑陋的事情之外)boost.log 使用 Meyer 的单例来保存核心上下文的实例,因此库用户无法控制核心上下文(及其拥有的对象)的生命周期,并且容易出现静态[un]初始化顺序惨败。

回答 1 投票 0

如何从子状态机访问状态机元素?

我正在使用 boost::msm 在机器人应用程序中进行状态管理。我有一个外部状态机,用于控制主流程并包括空闲、操作和错误等状态。操作...

回答 1 投票 0

将 Boost python 与 libtorch 结合使用

我正在尝试使用 Boost python 从 C++ 代码创建一个 python 包。然而,当包含 libtorchin 代码时,生成的 python 包显示奇怪的错误,例如 Boost.Python.ArgumentE...

回答 1 投票 0

Boost.Beast WebSocket 服务器 - 客户端连接上出现“读取错误:I/O 操作已中止”

我正在使用带有 SSL 的 Boost.Asio 和 Boost.Beast 构建 WebSocket 服务器。服务器接受连接,但我遇到了客户端在连接后不久就断开连接的问题。电子...

回答 1 投票 0

在没有CMake查找模块的情况下查找Boost(CMP0167)

我使用CMake版本3.30.5。我的 Boost 项目现在在调用 CMake 时发出此警告: CMake 警告(开发)位于 euler16_power_digit_sum/CMakeLists.txt:3 (find_package): 策略 CMP0167 未设置:...

回答 1 投票 0

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