草庐IT

BOOST_TEST_DYN_LINK

全部标签

c++ - 如何在 boost log 2.0 中设置 std::ios_base 标志,如 std::left?

我有一个广泛使用boostlog2.0的应用程序。现在我想为该应用程序设置一些默认标志,如std::setprecision(std::numeric_limits::digits10+1)、std::scientific和std::left。但是我该怎么做呢?一种方法是在我的主要功能的最开始创建一个记录器并创建一个虚拟日志消息。这将永久设置所需的标志。但是没有更好的方法来做到这一点吗?编辑回复:“OPshouldshowactualcode.”我有一个全局日志记录单例,称为L:classL{public:enumseverity_level{dddebug,ddebug,debug,

c++ - gtest,对 'testing::Test::~Test()' 的 undefined reference ,testing::Test::Test()

我使用apt-getinstalllibgtest-dev安装了gtest我正在尝试检查它是否有效。所以我在eclipse中编写了简单的测试代码。但是有错误,undefinedreferenceto'testing::Test::~Test()'undefinedreferenceto'testing::Test::Test()'相反,如果我将ATest类的继承更改为protected,错误就会消失,但是出现其他错误testing::Testisinaccessiblebaseof'ATest_AAA_Test'怎么了?#include#includeclassA{public:int

c++ - boost 中的 path::string() 和 path::generic_string() 有什么区别?

boost::path::string()和boost::path::generic_string()有什么区别,我应该什么时候使用它们? 最佳答案 这在thedocumentation中有明确说明;您只需阅读文档即可获得知识和理解。请从现在开始养成这样做的习惯。boost::路径::字符串在thenativepathnameformat中返回一个std::string.boost::path::generic_string在thegenericpathnameformat中返回一个std::string.何时使用它们中的每一个好吧

c++ - boost 结构和类的 fusion 序列类型和名称识别

我正在尝试为我的一个项目使用boostfusion,并且我正在弄清楚如何获取结构和类的类型名称和变量名称。#include#include#include#include#include#include#include#include#includeusingnamespaceboost::fusion;structFoo{intinteger_value;boolboolean_value;};classBar{intinteger_value;boolboolean_value;public:Bar(inti_val,boolb_val):integer_value(i_val),

c++ - 返回 Boost Graph 中连接的组件子图的列表

我在过滤原始图中具有相同组件的子图时遇到问题。我想将它们输出到子图的vector中。按照`connected_components中的示例,我尝试使其适应我的需要://CreateatypedeffortheGraphtypetypedefadjacency_list,property>Graph;//typedefsubgraphSubGraph;typedeftypenamegraph_traits::vertex_descriptorVertex;typedeftypenamegraph_traits::edge_descriptorEdge;typedefgraph_trait

c++ - boost::可选抽象类类型

我想要一个抽象类型的可选对象。然而,boost::optional对于抽象类型是失败的:#includeclassA{virtualintgetInt()=0;};classB:publicA{intgetInt(){return666;};};intmain(){boost::optionalmaybeAnA;boost::optionalanother(maybeAnA);};结果error:invalidnew-expressionofabstractclasstype‘A’只使用指针似乎也不是一个可行的解决方案,因为某些函数需要返回一个包含可选值的对象作为成员,尽管期望函数的调

c++ - 将 boost::log::expressions::attr< std::string > 转换为 std::string

在使用Boost.Log时,我试图保留我的TimeStamp格式化程序,例如:logging::add_file_log(keywords::file_name="my.log",keywords::format=(expr::stream("TimeStamp","%Y-%m-%d%H:%M:%S")("Line")("File")据说我不能使用其他形式的格式化程序,因为我将很难转换"TimeStamp"转换成我的自定义格式:staticvoidmy_formatter(logging::record_viewconst&rec,logging::formatting_ostream

c++ - 错误:使用已删除的函数'test::test (const test&) C++ 结合 vector

我有一个我不明白的问题。我有一个生成线程的类。一切都好。我制作了一个新对象-一切正常。如果我将这些存储在一个vector中以迭代我的代码将无法编译。我使用g++4.9i686。我制作了以下简短程序,它完全模拟了问题,因为真实代码相当广泛。如果有人可以澄清或给我一个对我的宠物项目非常有用的解决方案,因为我坚持这个。代码如下:#include#include#include#includeclasstest{public:test();voidsetstring(std::strings);~test(){}voidrunThread(){m_thread=std::thread(&tes

c++ - 如何将 `boost::static_visitor` 实例传递给函数

我正在使用boost::variant在我的项目中经常出现。我的同事们现在想出了传递特定boost::static_visitor实例的想法。以自定义访问类型。她有一些代码如下:#include#includetypedefboost::variantTVar;structVisitor1:publicboost::static_visitor{templateresult_typeoperator()(constT&){return42;}};structVisitor2:publicboost::static_visitor{templateresult_typeoperator(

c++ - Boost Variant 是否提供与 std 的 holds_alternative 类似的功能?

我在cppreference.com上找到了这段代码。我想知道boost是否为其变体类型提供了类似的功能。我发现boost文档真的很糟糕,找不到任何东西。intmain(){std::variantv="abc";std::cout(v)(v) 最佳答案 虽然不完全一样,但是可以使用基于指针的get函数:boost::variantv="abc";std::cout(&v)!=nullptr)(&v)!=nullptr) 关于c++-BoostVariant是否提供与std的holds_