The code compiled with GCC 4.9.2 without even any warning, but shows the following error in GCC 5.2.0:
error: use of deleted function ‘bool std::regex_match(const std::__cxx11::basic_string<_Ch_type, _Ch_traits, _Ch_alloc>&&, std::__cxx11::match_results<typename std::__cxx11::basic_string<_Ch_type, _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>&, const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, std::regex_constants::match_flag_type) [with _Ch_traits = std::char_traits<char>; _Ch_alloc = std::allocator<char>; _Alloc = std::allocator<std::__cxx11::sub_match<__gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> > > >; _Ch_type = char; _Rx_traits = std::__cxx11::regex_traits<char>; typename std::__cxx11::basic_string<_Ch_type, _Ch_traits, _Ch_alloc>::const_iterator = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >]’ if(std::regex_match(toString(index),result,re)){negative_flag = true;}
Piece of code that's throwing the error:
bool negative_flag=false; std::regex re("-[^-]*"); std::smatch result; if(std::regex_match(toString(index),result,re)){negative_flag = true;}
The error is in the if
line. What might be causing this?
Any way I solved it. I found these lines in regex.h
:
// _GLIBCXX_RESOLVE_LIB_DEFECTS // 2329. regex_match() with match_results should forbid temporary strings /// Prevent unsafe attempts to get match_results from a temporary string.
i.e it says regex_match
no longer permits temporary strings (which is returned from toString()
function in this case) with match_results. So something like this solved the problem:
std::string tmps = toString(index); if(std::regex_match(tmps,result,re)){negative_flag = true;}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With