-1
아래 코드는 regex_token_iterator에서 std :: vector로 값을 복사하지 못합니다. Visual Studio 2015에서는 매개 변수가있는 'std :: copy'가 안전하지 않을 수 있다고보고합니다.std :: regex_token_iterator를 std :: vector에 복사하는 방법은 무엇입니까?
누구나 수정 방법을 알고 계십니까?
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <regex>
int main()
{
// String to split in words
std::string line = "dir1\\dir2\\dir3\\dir4";
// Split the string in words
std::vector<std::string> to_vector;
const std::regex ws_re("\\\\");
std::copy(std::sregex_token_iterator(line.begin(), line.end(), ws_re, -1),
std::sregex_token_iterator(),
std::back_insert_iterator<std::vector<std::string>>(to_vector));
// Display the words
std::cout << "Words: ";
std::copy(begin(to_vector), end(to_vector), std::ostream_iterator<std::string>(std::cout, "\n"));
}
가 관련이 있는지 내가 확실히 모르겠어요,하지만 당신은 필요한 함수 벡터를 제공하고 있습니다 반복자. – chris
고마워, 나는 벡터에서 삽입 반복기를 전달하는 방법을 탐색 할 것이다. –
벡터가 비어 있습니다. back_inserter를 사용해야합니다. –