草庐IT

lines_std

全部标签

c++ - Clion 的 "Call to std::pair is ambiguous"但可以编译代码

我有一个函数可以在这种状态下编译,但给出“配对调用不明确”,但仅在ClionIDE中,编译没有问题,如果我添加任何随机的东西,警告就会消失,即使它最终导致编译器错误。std::pair>Config::foo(conststd::string&sec,conststd::string&key)const{returnstd::pair>(hasSection(sec)?(hasKey(sec,key)?Status::Success:Status::MissingKey):Status::MissingSec,hasKey(sec,key)?config_map.find(sec)->

c++ - MSVC (std::codecvt) 上的双字节编码:无法识别前导字节

我想使用std::codecvt::in()将以双字节代码页编码的字符串转换为UTF-16字符串关于Microsoft标准库实现(MSVC11)。例如,考虑以下程序:#include#includeintmain(){//KATAKANALETTERA(U+30A2)inShift-JIS(Codepage932)//http://msdn.microsoft.com/en-us/goglobal/cc305152charconstcs[]="\x83\x41";std::localeloc=std::locale("Japanese");//Output:"Japanese_Japa

c++ - 遍历 std::vector 以从 std::string 数组中查找匹配项,更简单的方法?

我循环遍历std::vector和std::string数组以从vector中找到匹配项。例子:#include#include#includeintmain(){std::coutmyVector;myVector.push_back("Word");myVector.push_back("Word2");myVector.push_back("Word4");myVector.push_back("Word6");myVector.push_back("Word7");std::stringmyStringArr[]={"Word","Word1","Word2","Word3",

windows - 批处理文件中的 git archive "The input line is too long. "错误

我设法从各种来源修改了我发现的脚本,以创建在2个变更集之间添加或更改的文件的存档。批处理脚本如下:setlocalenabledelayedexpansionsetoutput=for/f"delims="%%ain('gitdiff--name-only%1%2')do(setoutput=!output!"%%a")gitarchive-oexport.zipHEAD%output%endlocal这在今天之前一直很好用,突然间我收到了以下错误:Theinputlineistoolong.Thesyntaxofthecommandisincorrect.我已经确认造成这种情况的原因

windows - start.sh 中的 "line 36: cd: HOME not set"运行使用 Docker for Windows Installer v1.6.0 安装的 Boot2Docker

我已经使用DockerforWindowsInstallerv1.6.0在我的Windows笔记本电脑上安装了Docker。当我第一次运行start.sh脚本时,它会初始化并启动VM,但随后脚本给出错误“line36:cd:HOMEnotset”并退出:C:\ProgramFiles\Boot2DockerforWindows>start.shinitializing...starting...WaitingforVMandDockerdaemontostart...............................ooooooooStarted.WritingC:\Users\

浏览器中的 RStudio "next line"命令()不起作用

我想,您可以在RStudio中使用browser()命令来单步执行代码中的行。在许多情况下,这是可行的。但是,在R脚本中它似乎不起作用。这是一个最小的例子(只需在test.R中复制以下代码):print("1")browser()print("2")wrong#Produceserror,whichcannotbetrackedusingbrowserprint("3")(R-3.3.0,RStudio0.99.489)。感谢您的帮助!感谢@Batanichek,以下脚本解决了这个问题:{print("1")browser()print("2")wrongprint("3")}

windows - 混帐 : Self-made file has line-ending problems

因此,我有一个新的存储库,我正在尝试启动一个协作项目。我已经将.gitignore和.gitattributes(处理自动crlf)文件推送给它。我的.gitattributes文件是:#Setthedefaultbehavior,incasepeopledon'thavecore.autocrlfset.*text=auto#Explicitlydeclaretextfilesyouwanttoalwaysbenormalizedandconverted#tonativelineendingsoncheckout.*.ctext*.htext#Declarefilesthatwill

c++ - 如何优化 std::map insert() 函数?

解释我正在尝试的最好方法是使用这个示例(使用VisualStudio2008SP1编译):structELEMENT1{//ItsmembersELEMENT1(){//Constructorcode}~ELEMENT1(){//Destructorcode}};std::mapmap;std::pair::iterator,bool>resIns;ELEMENT1element;std::wstringstrKey;for(size_ti=0;i(strKey,element));//ThislinecallsELEMENT1constructor&destructortwice//

c++ - 如何修剪存储在 std::set 中的字符串?

我正在使用VS2012开发MFC应用程序。在此应用程序中,我想清理CString的容器。使用Trim()对象成员函数。首先,我使用了std::vector作为容器,如下图MCVE:#define_AFXDLL//CString#include//CString#includeintmain(){std::vectorv;v.push_back(_T("Test"));v.begin()->Trim();return0;}这会按预期进行编译和工作。然后,我想更换std::vector通过std::set.因此,我包括了#include而不是#include并更改了main()如下:int

c++ - 将 std::cout 重定向到新创建的控制台

这个问题在这里已经有了答案:Redirectingcouttoaconsoleinwindows(11个答案)关闭8年前。当您在Windows下创建C++控制台应用程序时,您会自动获得为您创建的控制台窗口,并将std::cout输出到控制台窗口。我有一个GUI应用程序,我还想为其创建一个控制台窗口。我可以使用AllocConsole()函数创建控制台窗口,但如何将std::cout重定向/附加到控制台,以便输出显示在控制台窗口中?