草庐IT

get_temporary_buffer

全部标签

c++ - Protocol Buffer 错误版本

我正在尝试安装Caffe库,但由于我的系统中安装了错误的protobuf版本,我遇到了编译问题。Infileincludedfrom.build_release/src/caffe/proto/caffe.pb.cc:5:0:.build_release/src/caffe/proto/caffe.pb.h:17:2:error:#errorThisfilewasgeneratedbyanolderversionofprotocwhichis#errorThisfilewasgeneratedbyanolderversionofprotocwhichis^.build_release/

c++ - 如何将多个 Protocol Buffer 的消息写入一个可追加的压缩文件?

我正在使用ProtocolBuffer的CodedOutputStream和FileOutputStream将多个消息按顺序序列化到一个文件中,如下所示://Fileisopenedusingappendmodeandwrappedinto//aFileOutputStreamandaCodedOutputStreamboolOpen(conststd::string&filename,intbuffer_size=kDefaultBufferSize){file_=open(filename.c_str(),O_WRONLY|O_APPEND|O_CREAT,//openmodeS_

c++ - 提升.Python : Getting a python weak reference to a wrapped C++ object

我已经使用Boost.Python包装了一个C++类。这些对象在C++端具有强引用(boost::shared_ptr),并且在Python中也可能存在断断续续的强引用。到目前为止,一切正常。但是,如果我从其中一个强引用创建一个python弱引用,那么一旦最后一个python强引用消失,这个弱引用就会被删除。我希望弱引用一直存在,直到C++端的最后一个强引用也消失为止。有可能实现吗?换句话说:有没有办法从python中找出特定的C++对象(由Boost.Python包装)是否仍然存在? 最佳答案 您如何持有对包装类的“C++强引用”

c++ - 我不明白在下面的代码中将 char buffer[] 与 X 类型的对象对齐的原因

Stroustrup在他的新书第151页中展示了以下使用类型说明符alignas的示例:Sometimes,wehavetousealignmentinadeclaration,whereanexpression,suchasalignof(x+y)isnotallowed.Instead,wecanusethetypespecifieralignas:alignas(T)means"alignjustlikeaT."Forexample,wecansetasideuninitializedstorageforsometypeXlikethis:voiduser(constvector

c++ - 访问 Protocol Buffer 扩展字段

我正在使用C++中的ProtocolBuffer。我的消息只有一个扩展范围。我想在不知道他们的名字的情况下访问所有的扩展字段,只使用他们的号码。我该怎么做??messageBase{optionalint32id=1;extensions1000to1999;}extendBase{optionalint32id2=1000;}到目前为止,我已经获得了ExtensionRange。constgoogle::protobuf::Descriptor::ExtensionRange*rng=desc->extension_range(0);std::cerrstartend但我不知道如何获

c++ - 对 C++ 中的 std::get_money 和 std::put_money 的混淆

我对C++函数感到困惑std::get_money在中定义头文件。get_money有什么用根据编程概念?我有以下代码使用std::get_money.#include//std::cin,std::cout#include//std::get_moneyintmain(){longdoubleprice;std::cout>std::get_money(price);if(std::cin.fail())std::cout当我输入100.25时,它返回100。输出和货币格式之间有什么关系?我读了this引用但无法理解关系。std::put_money也存在同样的混淆。,std::ge

c++ - JNI_CreateJavaVM : Buffer overrun if I throw an exception in case of failure

在C++项目中,我使用JNI调用API来启动JVM。我已经围绕JVM做了一些包装,因此我可以以面向对象的方式使用所有需要的部分。到目前为止效果很好。现在,如果JVM没有启动(JNI_CreateJavaVM返回值JNI_CreateJavaVM之后抛出异常,我遇到缓冲区溢出。如果我在没有JNI_CreateJavaVM调用的情况下引发异常,它会按预期工作。有人知道这里的问题是什么吗?或者如何调试?环境:Windows、VisualStudio2008JDK:jrockit27.6jdk16005,但也发生在SUNstockone上干杯多米尼克 最佳答案

c++ - 使用派生自 `std::get` 的元素在 `std::tuple` 上调用 `std::tuple` - 格式错误?

structY{};structX:std::tuple{};intmain(){std::get(std::make_tuple(X{}));}onwandbox当使用libc++时,上面的代码可以通过clang++编译并按预期工作。当使用libstdc++时,上述代码无法同时使用clang++和g++进行编译,并出现以下错误:include/c++/7.0.1/tuple:1302:36:error:nomatchingfunctionforcallto‘__get_helper(std::tuple&)’{returnstd::__get_helper(__t);}~~~~~~~

c++ - 为什么这个 get_index 实现在 VS2017 上失败了?

巴里给了我们thisgorgeousget_indexforvariants:templatestructtag{};templatestructget_index;templatestructget_index>:std::integral_constant...>(tag()).index()>{};按如下方式使用:usingV=variant;constexprconstsize_tN=get_index::value;//1它在Clang(OSX)中运行良好。但在VisualStudio2017中I'mgetting以下内容:(10):errorC2039:'index':is

php:file_get_contents不起作用

我有此代码://Aif(condition1){//Bif(condition2){//C}}和file_get_contents($url)。我希望此file_get_contents在“//c”中运行,但是我注意到了这一点:在适当的作品中,但是如果放入“//b”或“//c”,则相同的指令,不起作用,并且“不起作用,”条件1“和“条件2”都经过验证(将其他仪器放入b或c时,它们起作用)。我还尝试了此尝试/捕获声明,但没有成功:try{$content=file_get_contents($url);if($content===false){//THISisalwaysverified}}ca