c++ - G++-5 tr1/regex regex_replace could not be resolved -


i using g++-5 dialect option -std=c++0x , preprocessor symbol __gxx_experimental_cxx0x__ , trying use tr1/regex.

i use #include <tr1/regex> using namespace std::tr1; , regex reg("<[^>]*>"); trows no error. when use regex_replace(line, reg, ""); afterwards, following error output:

function 'regex_replace' not resolved  test.cpp    /cppuni/src line 72 semantic error  invalid arguments ' candidates are: #0 regex_replace(#0, #1, #1, const std::tr1::basic_regex<#3,#2> &, const ? &, std::bitset<unsigned long int11>) ? regex_replace(const ? &, const std::tr1::basic_regex<#1,#0> &, const ? &, std::bitset<unsigned long int11>) '   test.cpp    /cppuni/src line 72 semantic error 

i verified, line string.

i searched solution last couple of hours , find solutions involved attempted. unfortunately can't use boost/regex package.

is there solution issue?

edit:

#include <tr1/regex> #include <iostream> #include <string>  using namespace std;  int main(){   std::tr1::regex reg("<[^>]*>");     string line = "<day>22</day>";    if(line.find("<day>") != string::npos)     {         line =std::tr1::regex_replace(line, reg, "");         cout<<line<<endl;     }   return 0; } 

g++-5 -std=c++11 -d__gxx_experimental_cxx0x__ -wall test.cpp -o test.out

to have answered: user "baum mit augen" solved issue saying:

alright, in tr1::regex apparently need std::tr1::regex_replace(line, reg, string(""));. (though resulted in linker error in wandbox, maybe don't have legacy stuff installed, dunno.) should use std::regex c++11 instead, works fine showed above. – baum mit augen may 28 @ 11:10


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -