c++ - Can't seem to use this function in the Boost library -
i'm working on program uses boost regular expressions library, , i'm running issue while trying call boost::regex_match() function, i'm getting strange error i've never encountered before. here relevant code.
boost::regex pattern("regex redacted"); boost::cmatch what; xerces_std_qualifier cout << "enter xml document-building commands" << xerces_std_qualifier endl; while(true) { // take input user. std::string input; xerces_std_qualifier cout << ">> "; xerces_std_qualifier getline(in, input); if(boost::regex_match(input, what, pattern)) { // whatever } }
this took out of example code similar program instructor provided assignment. when try compile, error. if helps, i'm using netbeans 8.
xmldoc.cpp: in member function ‘void xmldoc::createdoc(std::istream&)’: xmldoc.cpp:164:51: error: no matching function call ‘regex_match(std::string&, boost::cmatch&, boost::regex&)’ xmldoc.cpp:164:51: note: candidates are: in file included /usr/include/boost/regex/v4/regex.hpp:145:0, /usr/include/boost/regex.hpp:31, xmldoc.cpp:13: /usr/include/boost/regex/v4/regex_match.hpp:44:6: note: template<class bidiiterator, class allocator, class chart, class traits> bool boost::regex_match(bidiiterator, bidiiterator, boost::match_results<iterator, allocator>&, const boost::basic_regex<chart, traits>&, boost::regex_constants::match_flag_type) /usr/include/boost/regex/v4/regex_match.hpp:44:6: note: template argument deduction/substitution failed: xmldoc.cpp:164:51: note: deduced conflicting types parameter ‘bidiiterator’ (‘std::basic_string<char>’ , ‘boost::match_results<const char*>’) in file included /usr/include/boost/regex/v4/regex.hpp:145:0, /usr/include/boost/regex.hpp:31, xmldoc.cpp:13: /usr/include/boost/regex/v4/regex_match.hpp:53:6: note: template<class iterator, class chart, class traits> bool boost::regex_match(iterator, iterator, const boost::basic_regex<chart, traits>&, boost::regex_constants::match_flag_type) /usr/include/boost/regex/v4/regex_match.hpp:53:6: note: template argument deduction/substitution failed: xmldoc.cpp:164:51: note: deduced conflicting types parameter ‘iterator’ (‘std::basic_string<char>’ , ‘boost::match_results<const char*>’) in file included /usr/include/boost/regex/v4/regex.hpp:145:0, /usr/include/boost/regex.hpp:31, xmldoc.cpp:13: /usr/include/boost/regex/v4/regex_match.hpp:68:13: note: template<class chart, class allocator, class traits> bool boost::regex_match(const chart*, boost::match_results<const chart*, allocator>&, const boost::basic_regex<chart, traits2>&, boost::regex_constants::match_flag_type) /usr/include/boost/regex/v4/regex_match.hpp:68:13: note: template argument deduction/substitution failed: xmldoc.cpp:164:51: note: mismatched types ‘const chart*’ , ‘std::basic_string<char>’ in file included /usr/include/boost/regex/v4/regex.hpp:145:0, /usr/include/boost/regex.hpp:31, xmldoc.cpp:13: /usr/include/boost/regex/v4/regex_match.hpp:77:13: note: bool boost::regex_match(const std::basic_string<chart, st, sa>&, boost::match_results<typename std::basic_string<chart, st, sa>::const_iterator, allocator>&, const boost::basic_regex<chart, traits>&, boost::regex_constants::match_flag_type) [with st = std::char_traits<char>; sa = std::allocator<char>; allocator = std::allocator<boost::sub_match<const char*> >; chart = char; traits = boost::regex_traits<char>; typename std::basic_string<chart, st, sa>::const_iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >; boost::regex_constants::match_flag_type = boost::regex_constants::_match_flags] /usr/include/boost/regex/v4/regex_match.hpp:77:13: note: no known conversion argument 2 ‘boost::cmatch {aka boost::match_results<const char*>}’ ‘boost::match_results<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, std::allocator<boost::sub_match<const char*> > >&’ /usr/include/boost/regex/v4/regex_match.hpp:85:13: note: template<class chart, class traits> bool boost::regex_match(const chart*, const boost::basic_regex<chart, traits>&, boost::regex_constants::match_flag_type) /usr/include/boost/regex/v4/regex_match.hpp:85:13: note: template argument deduction/substitution failed: xmldoc.cpp:164:51: note: mismatched types ‘const chart*’ , ‘std::basic_string<char>’ in file included /usr/include/boost/regex/v4/regex.hpp:145:0, /usr/include/boost/regex.hpp:31, xmldoc.cpp:13: /usr/include/boost/regex/v4/regex_match.hpp:94:13: note: template<class st, class sa, class chart, class traits> bool boost::regex_match(const std::basic_string<chart, st, sa>&, const boost::basic_regex<chart, traits>&, boost::regex_constants::match_flag_type) /usr/include/boost/regex/v4/regex_match.hpp:94:13: note: template argument deduction/substitution failed: xmldoc.cpp:164:51: note: ‘boost::cmatch {aka boost::match_results<const char*>}’ not derived ‘const boost::basic_regex<chart, traits>’
can me out here? i'm included library because have project exact same linker properties uses boost::regex_match function (minus cmatch object parameter), , works fine.
if you're going use std::string
input, have use boost::smatch
instead of boost::cmatch
. see http://www.boost.org/doc/libs/1_57_0/libs/regex/doc/html/boost_regex/ref/match_results.html. need change
boost::cmatch what;
to
boost::smatch what;
Comments
Post a Comment