草庐IT

BOOST_CHECK_EQUAL

全部标签

c++ - C++11 中的 BOOST scoped_lock 替换

我面临这样一种情况,我必须用C++11中的等效项替换BOOSTscoped_lock。在visualstudio2013下。由于c++11不支持scoped_lock,我不确定下面的替换代码是什么。我应该选择lock_guard还是try_lock?boost::mutex::scoped_lockobjectLock(ObjectVectorMutex,boost::try_to_lock);if(objectLock){//...}在代码中我有以下“等待”语句if(ObjectsCollection.empty()){//Thisiswherewewaittilsomethingi

c++ - boost::graph 中的 DFS 更改图形内容

最小的例子:#include#include#includestructvertex{intnumber;};structedge{};typedefboost::adjacency_listgraph_t;typedefboost::graph_traits::vertex_descriptorvertex_t;typedefboost::graph_traits::edge_descriptoredge_t;structvertex_visitor:publicboost::default_dfs_visitor{voiddiscover_vertex(vertex_tv,grap

c++ - 如何使用 boost::random_device 生成密码安全的 64 位整数?

我想做这样的事情:boost::random_devicerd;boost::random::mt19937_64gen(rd());boost::random::uniform_int_distributiondis;uint64_tvalue=dis(gen);但我读到梅森扭曲器在密码学上并不安全。但是,我还读到一个random_device可能是,如果它从/dev/urandom中提取数据,这可能在linux平台(我的主要平台)上。因此,如果random_device是非确定性随机的并且它用于播种梅森扭曲器(如上所示),这是否也使梅森扭曲器在密码学上是安全的(即使它本身不是)?我

c++ - Caffe中的CHECK & CHECK_EQ等类函数宏的定义具体在哪里?

正如我所注意到的,有很多类似函数的宏,例如CHECK、CHECK_EQ、...在Caffe头文件和源文件中经常使用,例如在blob.cpp中我们有:templatevoidBlob::FromProto(constBlobProto&proto,boolreshape){if(reshape){vectorshape;if(proto.has_num()||proto.has_channels()||proto.has_height()||proto.has_width()){//Usingdeprecated4DBlobdimensions--//shapeis(num,channe

c++ - boost 侵入式指针

我对boost的侵入式指针有点困惑。定义说:"Everynewintrusive_ptrinstanceincrementsthereferencecountbyusinganunqualifiedcalltothefunctionintrusive_ptr_add_ref,passingitthepointerasanargument.Similarly,whenanintrusive_ptrisdestroyed,itcallsintrusive_ptr_release;thisfunctionisresponsiblefordestroyingtheobjectwhenitsre

c++ - "Could not determine which "制作 "command to run. Check the "制作 "step in the build configuration."Qt 创建者

我安装了好几次qtcreator,但它从来没有像我现在的PC那样花钱;首先,我使用我的Pendrive(Qt5.8的)上一直有的安装程序,告诉我我无法下载一些存储库,我下载了相同安装程序的5.9版,结果相同。在尝试安装它几次但它没有加载后,我去了另一所房子,在那里我设法安装了它,尽管我必须非常清楚由于缺少库而导致的许多错误(在安装Qt5.9时)。在此之后,我不得不通过“windows更新”为我的win7操作系统下载sp1以运行Qtcreator,但后来,在加载、创建或运行项目时,我会在控制台中说(它是否是GUI并不重要)以下:“无法确定运行哪个”make“命令。检查构建配置中的”mak

c++ - 试图摆脱 C++ boost 警告

每当我在我的项目中加入boost时,我都会收到一百万条这样的警告。有谁知道我怎样才能摆脱警告?../depends\boost/config/abi_prefix.hpp(19):warningC4103:'depends\boost\config\abi_prefix.hpp':alignmentchangedafterincludingheader,maybeduetomissing#pragmapack(pop)我知道我可以执行#pragma来禁用警告,但我想知道这些警告的原因。 最佳答案 原因是boost不会在每个需要打包数

c++ - 在 shared_from_this() 中 boost weak_ptr_cast

我正在使用boost的共享指针,并使用enable_shared_from_this来启用返回指向this的共享指针。代码如下所示:classfoo:publicboost::enable_shared_from_this{boost::shared_ptrget(){returnshared_from_this();}}为什么shared_from_this会抛出weak_ptr_cast异常? 最佳答案 如果您在堆栈上声明了foo,那么就没有其他指向foo的共享指针。例如:voidbar(){foofooby;fooby.get

C++,boost asio,接收空终止字符串

如何使用boost::asio库从套接字中检索以null结尾的字符串? 最佳答案 m_socket=boost::asio::ip::tcp::socket(io_service);boost::asio::streambufreplyBuf;......boost::asio::read_until(m_socket,replyBuf,'\0');如果你想将streambuf转换为字符串:std::stringretVal((std::istreambuf_iterator(&replyBuf)),std::istreambuf_

c++ - 如何为 boost::bind 强制模板函数重载?

我正在尝试通过使用boost::bind和boost::contains为std::find_if创建谓词(来自提升/算法/字符串库)。以下代码段显示了我如何尝试实现此目的的两种方式。#include#include#include#include#includeintmain(intargc,char**argv){std::strings1("hellomom");std::strings2("byemom");boost::functionf=&boost::contains;std::coutcontain_hello=boost::bind(boost::contains,_