【发布时间】:2015-08-23 08:04:12
【问题描述】:
使用 GCC 4.9.2 编译的代码甚至没有任何警告,但在 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;}
抛出错误的一段代码:
bool negative_flag=false;
std::regex re("-[^-]*");
std::smatch result;
if(std::regex_match(toString(index),result,re)){negative_flag = true;}
错误在if 行中。这可能是什么原因造成的?
【问题讨论】: