boost regex 1.32/VC7.1 compile problem

I am trying to move my code from vc6.0 to vc71. Here is the part of code using boost regex: boost::wregex ee(L"[E|e],(\\w+),(.+)$"); boost::wcmatch mr; TString value=L"some char"; if (boost::regex_match(value, mr, ee)) { ... } Those code compiled with UNICODE and was ok on vc6.0. But when I compile with VC71, it gives me error c2664: ============ d:\s\AEM\AEM6.0\source\AEMCore\AEMRulesCfgReg.cpp(176): error C2664: 'bool boost::regex_match<std::char_traits<wchar_t>,std::allocator<_Ty>,std::allocator<boost::sub_match<BidiIterator>>,wchar_t,traits,Allocator>(const std::basic_string<_Elem,_Traits,_Ax> &,boost::match_results<std::basic_string<_Elem,_Traits,_Ax>::const_iterator,std::allocator<boost::sub_match<BidiIterator>>> &,const boost::reg_expression<charT,traits,Allocator> &,boost::regex_constants::match_flag_type)' : cannot convert parameter 2 from 'boost::wcmatch' to 'boost::match_results<BidiIterator,Allocator> &' with [ _Ty=wchar_t, BidiIterator=const unsigned short *, traits=boost::regex_traits<wchar_t>, Allocator=std::allocator<wchar_t>, _Elem=wchar_t, _Traits=std::char_traits<wchar_t>, _Ax=std::allocator<wchar_t>, charT=wchar_t ] and [ BidiIterator=std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>::const_iterator, Allocator=std::allocator<boost::sub_match<const unsigned short *>> ] ================== also, I got lots warning C4018: '<' : signed/unsigned mismatch, although that's ok for me right now. Thanks for any help. frank

Please try to use "wsmatch" instead of "wcmatch." It will work well. But I don't know why such a error occurs... frank fu <omni123@gmail.com> wrote:
I am trying to move my code from vc6.0 to vc71. Here is the part of code using boost regex:
boost::wregex ee(L"[E|e],(\\w+),(.+)$"); boost::wcmatch mr; TString value=L"some char"; if (boost::regex_match(value, mr, ee)) { ... }
Those code compiled with UNICODE and was ok on vc6.0. But when I compile with VC71, it gives me error c2664:
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- TAKAHASHI Daisuke d_takahashi@sannet.ne.jp -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

I found why such a error occurs. According to your call "boost::regex_match(value, mr, ee)", the type of the first parameter is wstring (not const wchar_t*), and of the second is match_results<const wchar_t*>. So, the compiler selected the following overload from six. bool regex_match ( const std::basic_string<...>&, match_results < std::basic_string::const_iterator >&, const basic_regex<...>&, match_flag_type ) This overload requires a reference to match_results with std::basic_string::const_iterator template parameter. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This meens that the cast match_results < const wchar_t* >&, to match_results < std::basic_string::const_iterator >& was needed. Such a cast can be done successfully in VC6, but I think VC7.1's strict check did not allow it. Thanks. -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- TAKAHASHI Daisuke daisuke@ist.osaka-u.ac.jp -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

boost::wregex ee(L"[E|e],(\\w+),(.+)$"); boost::wcmatch mr; TString value=L"some char"; if (boost::regex_match(value, mr, ee)) { ... }
Those code compiled with UNICODE and was ok on vc6.0. But when I compile with VC71, it gives me error c2664:
With VC7.1 basic_string::const_iterator is no longer a pointer type, so wcmatch is the wrong typedef to use: use wsmatch instead (you should have been using it before, it's just that your code compiled "by accident" with VC6). John.

Thanks a lot! On Wed, 2 Mar 2005 10:59:56 -0000, John Maddock <john@johnmaddock.co.uk> wrote:
boost::wregex ee(L"[E|e],(\\w+),(.+)$"); boost::wcmatch mr; TString value=L"some char"; if (boost::regex_match(value, mr, ee)) { ... }
Those code compiled with UNICODE and was ok on vc6.0. But when I compile with VC71, it gives me error c2664:
With VC7.1 basic_string::const_iterator is no longer a pointer type, so wcmatch is the wrong typedef to use: use wsmatch instead (you should have been using it before, it's just that your code compiled "by accident" with VC6).
John.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
frank fu
-
John Maddock
-
TAKAHASHI Daisuke