草庐IT

SRE_Match

全部标签

C++11 std::regex_match 返回额外字符

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Isgcc4.7buggyaboutregularexpressions?我遵循了http://www.cplusplus.com/reference/std/regex/regex_match/上的示例并在Ubuntu12.0464位上使用g++版本4.6.3编译以下是我的输出:stringliteralmatchedstringobjectmatchedrangematchedstringliteralwith3matchesstringobjectwith3matchesrangewith3matche

c++ - OpenCV 错误 : Sizes of input arguments do not match (The operation is neither 'array op array' )

我正在做一个在树莓派上使用opencv的项目。我遇到了一个看起来很简单的障碍,但我无法解决问题。首先,这是我的代码的一部分:{gray=cvarrToMat(py);///cvShowImage("camcvWin",py);//displayonlygraychannelif(img_num%2==1){cv::imwrite("/home/pi/test/Gray_2Image1.jpg",gray);}elseif(img_num%2==0){cv::imwrite("/home/pi/test/Gray_2Image2.jpg",gray);cv::Matimg2=cv::im

c++ - regex_match (""8 秒,regex (".{40000}"));?

更新2:实际上是regex(".{40000}");。仅此一项就已经花费了那么多时间。为什么?regex_match("",regex(".{40000}"));在我的PC上花费将近8秒。为什么?难道我做错了什么?我在i7-6700上的Windows10上使用来自MinGW的gcc4.9.3。这是一个完整的测试程序:#include#include#includeusingnamespacestd;intmain(){clock_tt=clock();regex_match("",regex(".{40000}"));cout我如何编译和运行它:C:\Users\...\coding>

c++ - 谷歌模拟 : How to configure custom message to explain match failure

如果匹配失败,Googlemock会打印如下消息:test.cpp:112:EXPECT_CALL(mock_obj,foo(MyMatcher(bar)))...Expectedarg#0:isequalto[1,2;3,4]Actual:{1}Expected:tobecalledonceActual:nevercalled-unsatisfiedandactive使用自定义匹配器MyMatcher我可以定义一个描述字符串,用于在匹配失败时生成失败消息。但它只定义了消息的Expectedarg#0部分。有什么方法可以自定义Actual的打印方式吗?在我的例子中,我不能为bar的类重

C++ 模板 : cannot match the last template in variadic class template

我正在学习C++11可变参数模板并创建了一个模板结构来计算给定列表的最大数量并尝试了:#include#includetemplatestructmax:std::integral_constantb?max::value:max::value)>{};templatestructmax:std::integral_constantb?max::value:max::value)>{};templatestructmax:std::integral_constant{};intmain(){std::cout::value但是g++提示:test.cc:7:58:error:wrong

c++ - 错误 : no match for ‘operator<’ in ‘__x < __y’ when trying to insert in two map

在代码中有两个映射。一个存储对和另一个存储,其中值是具有5个变量的类,数据类型为字符串、整数、字符串、整数、整数。但是在插入第二个映射期间,我收到错误g++错误:尝试在map中插入时,'__x如何解决。classValues{private:std::stringC_addr;intC_port;std::stringS_addr;intS_port;intC_ID;public:Values(std::string,int,std::string,int,int);voidprintValues();};Values::Values(std::stringCaddr,intCport

C++ regex_match 不工作

这是我的部分代码boolCSettings::bParseLine(constchar*input){//_asmINT3std::stringline(input);std::size_tposition=std::string::npos,comment;regexcvarPattern("\\.([a-zA-Z_]+)");regexparentPattern("^([a-zA-Z0-9_]+)\\.");regexcvarValue("\\.[a-zA-Z0-9_]+[]*=[]*(\\d+\\.*\\d*)");std::cmatchmatchedParent,matched

c++ - "No match for operator="试图在 C++ 中遍历映射

我正在尝试遍历定义如下的map:std::map>ridx_;现在我尝试在以下重载运算符的友元函数中遍历ridx_(它是一个类的私有(private)成员)std::ostream&operator>::iteratorit;//Thefollowingisline34for(it=m.ridx_.begin();it!=m.ridx_.end();it++)osfirst但是g++错误输出:SMatrix.cpp:34:error:nomatchfor'operator='in'it=m->SMatrix::ridx_.std::map::beginwith_Key=unsigned

c++ - 为什么 regex_match 抛出 "complexity exception"?

我正在尝试测试(使用boost::regex)文件中的一行是否仅包含由空格分隔的数字条目。我遇到了一个我不明白的异常(见下文)。如果有人能解释为什么抛出它,那就太好了。也许我在这里以定义模式的方式做了一些愚蠢的事情?这是代码://regex_test.cpp#include#include#includeusingnamespacestd;usingnamespaceboost;intmain(){//Mybasicpatterntotestforasinglenumericexpressionconststringnumeric_value_pattern="(?:-|\\+)?[[

c++ - 编译cuda文件报错: "runtime library" mismatch value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in vectorAddition_cuda. o

我尝试在Qt5.2和MSVC2012环境下编译一个cuda文件。在开始我的项目之前,我仔细阅读了问题并回复:CompilingCudacodeinQtCreatoronWindows.但是即使我简单地复制代码并在qt中生成2个文件,仍然会弹出一些错误/main.cpp/vectorAddition.cu错误是:errorLNK2038:mismatchdetectedfor'RuntimeLibrary':value'MDd_DynamicDebug'doesn'tmatchvalue'MTd_StaticDebug'invectorAddition_cuda.o我完全不知道如何修复这