2017-04-30 18 views
0

で宣言されていなかった私は、C++を習得しようとしているので、私は短いprogram.thisを書いた私のC++コードされています。私はこのエラーを取得する'cbegin' がこの範囲

#include <iostream> 
#include <string> 
#include <regex> 

using namespace std; 

int main() 
{ 
string line; 
regex email(R"(\[email protected](\w+\.)+\w+)"); 
while (getline(cin, line)) { 
    smatch matches; 
    auto current = cbegin(line); 
    auto last = cend(line); 
    while (current != last) 
    { 
     if (regex_search(current, last, matches, email)) 
     { 
      ssub_match match = matches[0]; 
      current = match.second; 
      cout << match.str() << endl; 
     } 
     else 
     { 
      break; 
     } 
    } 
} 
return 0; 
} 

=== Build file: "no target" in "no project" (compiler: unknown) === 

C:\Users\Public\Documents\CPP Scripts\usingStringType.cpp||In function 'int main()': 
C:\Users\Public\Documents\CPP Scripts\usingStringType.cpp|13|error: 'cbegin' was not declared in this scope 
C:\Users\Public\Documents\CPP Scripts\usingStringType.cpp|14|error: 'cend' was not declared in this scope 

=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 1 second(s)) === 
+0

どのようなコンパイラですか?コンパイラはどうやって呼びますか? –

答えて

0

実行中のバージョンであるかどうかわかりませんが、その場合はcbegin/cendが<イテレータ>になるはずです。もしそうでないなら(C++ 14が追加されたと思います)、line.cbegin()line.cend()を使うだけです。