I'm trying to split a string with a regular expression in C++. Here's the minimum repro:
#include <string>
#include <regex>
int main()
{
std::string str("abc");
std::string regex("b");
std::regex_token_iterator<std::string::const_iterator> a(str.begin(), str.end(), std::regex(regex), -1);
}
This program gives me a compile error: attempting to reference a deleted function
error C2280: 'std::regex_token_iterator<std::_String_const_iterator<std::_String_val<std::_Simple_types<_Ty>>>,char,std::regex_traits<char>>::regex_token_iterator(_BidIt,_BidIt,const std::basic_regex<char,std::regex_traits<char>> &&,int,std::regex_constants::match_flag_type)': attempting to reference a deleted function
But I feel like I've set it up correctly. Why am I getting this error and what do I need to change to get it to compile?
I was working from this gist as an example, but I can't get it to compile either.
I'm building with Microsoft Visual Studio 2017 15.8.4