jjzjj

basic_stringstream

全部标签

c++ - 如何将 basic_filebuf 与 char 以外的元素类型一起使用?

假设我想使用basic_filebuf读取文件的内容。我有一个名为boost::uintmax_t的类型,它的大小为8字节。我正在尝试编写以下内容:typedefbasic_filebuffile;typedefistreambuf_iteratorifile;filef;vectordata,buf(2);f.open("test.txt",std::ios::in|std::ios::binary);f.pubsetbuf(&buf[0],1024);ifilestart(&f),end;while(start!=end){data.push_back(*start);start+

c++ - stringstream::operator>> 只读取,不从流中提取下一个标记

我怎样才能只读取第一个新的“token”(标准的非空白字符序列,由运算符精美地提取>>)而不将其从流中删除?我可以提取字符串,检查它是否需要放回去,并重置内部流迭代器吗?我认为这可能有效,但不知道如何实现...例子:#includeusingstd::string;#includeusingstd::stringstream;intmain(){strings("teststring\\blablie");stringstreamss(s);stringtoken;while(ss>>token){if("\\"==token)break;elsecouttellg和seekg在流提取

c++ - Direct3D11(C++) : Rendering (basic) question

我一直在关注一本关于使用D3D11进行游戏编程的基础知识的书。我现在了解Direct3D的绝对基础知识:)但是……我有一个问题。在书中,我总是不得不一次制作一个演示。现在,我正在尝试用它制作2D游戏。因为我不想习惯坏习惯所以我需要你的建议。在书中,我总是必须定义一个(结构VertexPos与texcoord和位置成员)或(结构VertexPos只有一个XMFLOAT3位置成员)。在我制作的游戏中,我希望能够绘制没有纹理的实体表面和有纹理的表面。我不确定如何做到这一点,更不用说高效地做到这一点了。这是我的渲染函数:voidGameSpriteDemo::Render(){if(m_pD3

c++ - boost::interprocess::basic_string 作为 std::string

我正在尝试用constboost::interprocess::basic_string&替换返回conststd::string&的类方法。我面临的主要挑战是这两个类之间的不兼容性,尽管它们的实现相似。为了更清楚的解释,我将把它放入代码中classA{std::stringm_str;conststd::string&StrVal(){returnm_str;}}现在这个类看起来像这样:typedefboost::interprocess::allocatorShmemAllocatorChar;typedefboost::interprocess::basic_string,Shm

c++ - 文件 basic_socket.hpp 中的 lib boost asio 1.47.0 出错

当我尝试编译时,以下代码出现错误:voidServer::accept(void){Network::ptrconnection=Network::initialize(this->my_acceptor.get_io_service());this->my_acceptor.async_accept(connection->socket(),bind(&Server::endCmd,this,*connection,placeholders::error));}voidServer::endCmd(Networkconnection,constboost::system::error

c++ - 使用 stringstream 读取浮点值的奇怪失败

我有以下简单代码,它使用c++stringstream读取浮点值(double)。我使用stringstream::good检测读取是否成功。奇怪的是,值被读入float变量,但是good()返回false。底部的代码返回:failed:3.14159我在mingw32下使用gcc4.8.1编译代码,使用g++-std=c++11test.cpp。知道为什么这个读法不是好吗?判断float实际读取成功的正确方法是什么?谢谢#include#includeusingnamespacestd;voidreadFloat(strings){doublei=0!;stringstreamss(

【Web】NSSCTF Round#18 Basic个人wp(部分)

目录①门酱想玩什么呢?②Becomeroot①门酱想玩什么呢?先试一下随便给个链接不能访问远程链接,结合评论区功能,不难联想到xss,只要给个评论区链接让门酱访问就可我们研究下评论区从评论区知道,要让门酱玩元梦之星,考虑直接document.location="https://ymzx.qq.com/";尝试传了发现不能起作用跳转,估计是这些被html实体化了那咋整呢,题目里还提供了评论插入图片功能我们就按示例传一下(必须以http://开头,否则不能解析为图片) 链接是插入到了src中,我们可以直接用">闭合img标签评论传http://">document.location="https:

c++ - 为什么 GCC 不允许我创建 `inline static std::stringstream` ?

我会直接去MCVE:#includestructA{inlinestaticstd::stringstreamss;};海湾合作委员会7.2和7.1refusetocompile它有以下错误:error:nomatchingfunctionforcallto'std::__cxx11::basic_stringstream::basic_stringstream()'inlinestaticstd::stringstreamss;^~Infileincludedfromblah:1:0:/opt/compiler-explorer/gcc-7.2.0/include/c++/7.2.0

c++ - C++ 变量的定义,Basic/6 部分

[basic]p6状态:Avariableisintroducedbythedeclarationofareferenceotherthananon-staticdatamemberorofanobject.Thevariable'sname,ifany,denotesthereferenceorobject.inta=0;//declarationofanobject,thisintroducesthevariablex,andanobjectiscreatedint{0};//notadeclarationofavariable,thisdoesnotintroduceavaria

c++ - 实例化 ActiveX 控件后,Excel 中出现 Visual Basic 运行时错误 -2147319765 (8002802b) 的原因是什么?

我已经使用C++创建了一个ActiveX控件。我使用VisualBasic代码在Excel工作表中实例化控件。我只能运行VB脚本一次,后续运行在尝试访问“ActiveSheet”变量时会导致以下运行时错误:MicrosoftVisualBasicRun-timeerror'-2147319765(8002802b)':AutomationerrorElementnotfound我正在尝试找出导致此错误的原因以及如何修复它?作为实验,我尝试创建一个由VisualStudio向导(在VS2005和2008中)生成的简单ActiveX控件。我没有在这个测试用例中添加或修改任何代码。简单的测试