When running the following
bool my_compare(const std::string& string_1, const std::string& string_2)
{
const boost::regex str_re("so(m)e_(r)e(g)ex");
boost::smatch str_match;
size_t one;
uint8_t two;
size_t three;
if( boost::regex_search(string_1, str_match, str_re) ) {
one = boost::lexical_cast<size_t>( std::string(str_match[1].first, match[1].second) );
two = boost::lexical_cast<uint8_t>( std::string(str_match[2].first, match[2].second) );
three = boost::lexical_cast<size_t>( std::string(str_match[3].first, match[3].second) );
}
size_t four;
uint8_t five;
size_t six;
if( boost::regex_search(string_1, str_match, str_re) ) {
four = boost::lexical_cast<size_t>( std::string(str_match[1].first, match[1].second) );
five = boost::lexical_cast<uint8_t>( std::string(str_match[2].first, match[2].second) );
six = boost::lexical_cast<size_t>( std::string(str_match[3].first, match[3].second) );
}
return false;
}
int main()
{
my_compare(some_string1, some_string2);
return 0;
}
I'm getting the following error, which I don't understand:
terminate called after throwing an instance of 'boost::exception_detail::clone_impl
' what(): bad lexical cast: source type value could not be interpreted as target
str_matchandmatchsupposed to be the same? It helps to post code that compiles.match.