c++ - std::regex_replace does not take fewer than 6 arguments -


I am trying to learn how to use the regex library in c ++ 11. On Ubuntu 13.10, I am trying to compile the following example:

  // regex_replace example #include & lt; Iostream & gt; #include & lt; String & gt; # Include & lt; Regex & gt; #include & lt; Iterator & gt; Int main () {std :: string s ("There is a follow-up in the string \ n"); Std :: regex e ("\\ b (sub) ([^] *)"); // match words starting with "sub" // using string / c-string (3) version: std :: cout & lt; & Lt; Std :: regex_replace (S, E, "sub $ 2"); // Category / c-string (6) version usage: std :: string result; Std :: regex_replace (std :: back_inserter (results), s.begin (), s.end (), e, "$ 2"); Std :: cout & lt; & Lt; result; // with the flag: std :: cout & lt; & Lt; Std :: regex_replace (S, E, "$ 1 and $ 2", std :: regex_constants :: format_no_copy); Std :: cout & lt; & Lt; Std :: endl; Return 0; }  

with the command:

  $ g ++ -std = c ++ 11 -o file file.cc  

I get the following output:

  file.cc13: 48: error: 'regex_replace (std :: string & amp;; std :: regex & const char [7 ]) ' 

What am I doing wrong ?! I do not have much hair hair on my head ... thanks in advance

Unfortunately, GCC 4.9 has not been released yet, but if you need this functionality then there is enough stable to go with the trunk build.

Alternatively, let's reset or go.


Comments