草庐IT

product_info

全部标签

c++ - 添加多个相同类型的 boost::error_infos 到一个 boost::exception

#include#includestructmyexception:virtualboost::exception,virtualstd::exception{};typedefboost::error_infoinfo;voidmain(){try{BOOST_THROW_EXCEPTION(myexception()这将输出[structtag_info*]=2我明白为什么会这样,但宁愿让它输出[structtag_info*]=1[structtag_info*]=2我当然可以typedefinfo作为boost::error_info>然后将所有信息累积在std::vector

c++ - ROS_INFO_STREAM 不打印

我正在尝试在叠瓦式try...catch中使用ROS_INFO_STREAM,但我只有顶级输出这是一小段代码:voidfailure(){try{//throwstd::length_errorstd::string("abc").substr(10);}catch(...){ROS_ERROR_STREAM("ROSfailure()");//printOKstd::cout输出:ROScallingROSfailure()coutfailure()coutcallfunction我的猜测是ROS_ERROR_STREAM看起来缓冲了,但作为错误输出它不应该。我正在运行ROSGroo

c++ - 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error>>

我创建了客户端应用程序。当我发送单个消息clientsever时它工作正常。但是当我出于性能目的发送大量消息时,客户端会以两种不同的方式崩溃:(gdb)runStartingprogram:/home/x64joxer/workerGenerators/Worker2/worker-t-i192.168.0.6-p6000-d5-l//home/x64joxer/workerGenerators/Worker2/[Threaddebuggingusinglibthread_dbenabled]Usinghostlibthread_dblibrary"/lib/x86_64-linux-

c++ - 我们能否在运行时确定两个 type_info 是否可转换?

有没有办法从两个const::std::type_info中判断对象,让我们将它们命名为B和D如果D描述的类型是从类型B派生的?我问是因为我想删除我得到的对象的类型,但稍后能够检查它是否可以安全地提升。void*data;const::std::type_info*D;templatevoidstore(D&&object){D=&typeid(object);data=::std::addressof(object);}templateB&load(){//if(typeid(B)!=(*D))throw::std::bad_cast{};return*reinterpret_cas

c++ - type_info 不考虑 cv 限定符 : is this right?

这段代码打印1是正确的行为还是g++4.5的怪癖?#include#includeusingnamespacestd;intmain(){structA{};cout我认为cv限定符的不同类型作为非常不同的类型受到威胁,即使较少的cv限定类型可以隐式转换为更多cv限定的类型。 最佳答案 typeid根据C++标准(摘自ISO/IEC14882:2003的§5.2.8)忽略cv限定符:Thetop-levelcv-qualifiersofthelvalueexpressionorthetype-idthatistheoperandof

c++ - libpng 在 png_read_info() 上崩溃

我正在尝试在vs2013中使用libpng1.2.10读取一个png文件。我下载了最新的zlib并编译了pnglib,效果很好。现在我正在尝试加载一个文件:int*w=&width;int*h=&height;constchar*name=file.c_str();FILE*png_file=fopen(name,"rb");if(!png_file){std::cerr不幸的是我得到了Unhandledexceptionat0x77D78E19(ntdll.dll)inSimpleShader.exe:0xC0000005:Accessviolationwritinglocation

命令“ python setup.py egg_info”失败,错误代码1 in/tmp/pip-build-build-fkyx6m64/misaka/

我在Fedora25上使用Django1.11。我正在使用虚拟环境,并且在尝试安装misaka:pip安装misaka时我收到以下错误:命令“pythonsetup.pyegg_info”失败,错误代码1在/tmp/pip-build-build-fkyx6m64/misaka/这是追溯:Collectingdjango-misakaDownloadingdjango-misaka-0.2.1.tar.gzCollectinghoudini.py(fromdjango-misaka)Downloadinghoudini.py-0.1.0.tar.gzCollectingmisaka(fromd

c++ - CMake 生成的 Xcode 项目无法找到从 Xcode 构建的二进制 "Products"

我正在尝试使用CMake生成的Xcode项目。构建时一切看起来都很好,除了Xcode找不到构建的二进制文件。下面是我在成功构建产品后截取的屏幕截图。我可以在项目源目录中看到它们。但是,请注意Xcode显示红色“HelloWorld”,这意味着它找不到产品。配置:Lion10.7.2上的CMake2.8.6和Xcode4.2这是CMakeLists.txtproject(HelloWorld)add_executable(${PROJECT_NAME}HelloWorld.cpp)这是HelloWorld.cpp的源码#includeintmain(){std::cout我尝试直接从Xc

c++ - 性能差异:std::accumulate vs std::inner_product vs Loop

今天,我想分享一些在尝试实现这个简单操作时让我大吃一惊的事情:我发现了执行相同操作的不同方法:通过使用std::inner_product。实现谓词并使用std::accumulate函数。使用C风格的循环。我想通过使用QuickBench并启用所有优化来执行一些基准测试。首先,我比较了两个具有浮点值的C++替代方案。这是通过使用std::accumulate使用的代码:constautopredicate=[](constdoubleprevious,constdoublecurrent){returnprevious+current*current;};constautoresul

c++ - 尽管包含 <typeinfo> ,但 Clang 拒绝 type_info 为不完整

我不明白为什么Clang会拒绝以下代码:#include#includeconstchar*get_name(conststd::exception_ptreptr){returneptr.__cxa_exception_type()->name();}intmain(){}GCC没问题,但是Clang提示type_info是一个不完整的类型:$g++-4.7-std=c++0x-O3-Wall-Wextrat.cc-ot$clang++-3.2-std=c++0x-O3-Wall-Wextrat.cc-ott.cc:6:37:error:memberaccessintoincompl