jjzjj

basic_istream

全部标签

c++ - istream 没有完全恢复已放入 stringstream 的内容

我使用以下设置:#includeusingnamespacestd;classfoo{public:voidbar(istream&in,intn){vector>q;intx,y,a,b;for(q.clear();in>>x>>y>>a>>b;q.push_back(make_tuple(x,y,a,b)));assert(n==q.size());}};intmain(){stringstreamss;for(inti=0;ibar(ss,100);}事实上,我的代码比这更复杂,但我的想法是将东西(准确地说是longlongint)放入stringstream并调用一个函数,将创

c++ - 为什么 basic_stringbuf 和 basic_filebuf 移动构造函数具有实现定义的行为?

来self的C++标准拷贝[§27.8.2.1p4]:basic_stringbuf(basic_stringbuf&&rhs);Effects:Moveconstructsfromthervaluerhs.Itisimplementation-definedwhetherthesequencepointersin*this(eback(),gptr(),egptr(),pbase(),pptr(),epptr())obtainthevalueswhichrhshad.Whethertheydoornot,*thisandrhsreferenceseparatebuffers(ifan

c++ - 错误:无法将 std::vector<std::basic_string<char>> 转换为 std::string*

作为C++的新手,我曾尝试在我的一个程序中创建一个简单的void函数以显示数组。但是,如标题所示,存在错误。我认为这是一个问题,因为我试图用与函数参数不同形式的数组来调用它。我不确定如何修改它。#include#includeusingnamespacestd;voiddisplay_array(stringarr[]){inti;for(i=0;ipaths;cout>current;while(current!="0"){paths.push_back(current);cin>>current;}display_array(paths);}感谢任何帮助。

c++ - 对 Visual Basic 6 ListView 的自动化支持

我需要通过自动化接口(interface)(使用C++/C#编码)获取控件的值/文本。我试过UIAutomationAPI这是Inspect捕获的一些结果:UIAutomation将这些控件识别为pane,我无法正常获取ListView文本项或获取/设置slider值。尝试使用其他工具,如MSAA,AutomationSpy给出相同的结果。经过研究,发现类名如ListView20WndClass,Slider20WndClass,...的控件属于VisualBasic6控件。那么,有没有API也可以支持这些类型的控制呢?备注1:有一个名为Ranorex的工具可以支持这些控件(遗憾的是,

c++ - 我如何在 wxWidgets 中重定向标准输入(istream)?

我正在尝试弄清楚如何将istream重定向到wxwidgets。我能够完成重定向ostream,方法如下(所以你知道我的意思):wxTextCtrl*stdoutctrl=newwxTextCtrl(...);wxStreamToTextRedirectorredirect(stdoutctrl);//Redirectostreamstd::cout我现在已经搜索了一段时间,但我找不到我将istream重定向到某种wx-input(所以“cin”实际上会提示用户通过wxWidgets输入)。 最佳答案 不,没有内置的方法可以做到这一

c++ - istream 和 ostream 跨平台

假设我想在我的大端机器上写这个an_ostream_implmy_output_on_BE;my_output_on_BE这是在我的小端机器上an_istream_implmy_input_on_LE;__int32value;my_input_on_LE>>value;assert(value==0x1234);是否有允许这样做的istream/ostream实现?例如。总是以BigEndian(或任何格式)流式传输数字? 最佳答案 如果您需要在机器之间共享比单个整数更复杂的数据,我衷心推荐GoogleProtocolBuffer

c++ - 具有弹出功能的 istream

这个问题在这里已经有了答案:ReadingpopenresultsinC++(2个答案)关闭7年前。我有一个接受istream类的函数。我需要能够使用gzip数据。在C++标准中是否有类似istream的类具有类似popen()的功能?或者,有没有办法将FILE*转换为istream?

c++ - experimental::basic_string_view<> 是否适用于右值?

我不是100%确定以下代码在语义上是正确的:#include#includeintmain(){std::stringstr="lvaluestring";std::experimental::string_viewview_lvalue(str);std::experimental::string_viewview_rvalue(std::string{"rvaluestring"});std::coutLiveonWandbox问题:我可以合法地将右值绑定(bind)到std::experimental::basic_string_view吗?,还是只是UB?如果是,它是如何工作的

c++ - 在cpp中的istream前面插入一个字符串

我的问题是我想在iostream前面附加一些字符串。你可以在std::cin前面说。#include#includevoidprint(std::istream&in){//functionnottobemodifiedstd::stringstr;in>>str;std::cout>str;std::cout我想要实现功能,如果我提供像这样的输入$catfile.txthelpmetosolvethis.$$./a.out欢迎任何形式的帮助。你可以使用boost::iostream来实现它。 最佳答案 流不是容器。它是数据流。您无

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+