STL string::const_iterator problem converting code from VC6 to VS2008.
-
The following code compiled fine on VC6, but won't on VS2008. The first param to regex_search() does not match any of the function signatures.
string::const\_iterator ssource\_pos; const boost::match\_flag\_type mflags = boost::match\_default | boost::match\_not\_dot\_newline | boost::format\_default; const boost::regex re( sre, boost::regex::perl | boost::regex::icase ); boost::match\_results what; const bool bstat = boost::regex\_search( ssource\_pos, what, re, mflags );
In VC6 it must have been happy using:
bool regex_search(const basic_string<chart,>& s,
match_results<<br mode="hold" /> typename basic_string<chart,>::const_iterator,
Allocator>& m,
const basic_regex<chart,>& e,
match_flag_type flags = match_default);but in VS2008 I get:
1>s:\libs\saigcontrols\strlib\sgstr_parse.cpp(628) : error C2780: 'bool boost::regex_search(const std::basic_string<chart,st,sa> &,const boost::basic_regex<chart,traits> &,boost::regex_constants::match_flag_type)' : expects 3 arguments - 4 provided
1> s:\libs\boost_1_33_1\boost\regex\v4\regex_search.hpp(152) : see declaration of 'boost::regex_search'
1>s:\libs\saigcontrols\strlib\sgstr_parse.cpp(628) : error C2780: 'bool boost::regex_search(const charT *,const boost::basic_regex<chart,traits> &,boost::regex_constants::match_flag_type)' : expects 3 arguments - 4 provided
1> s:\libs\boost_1_33_1\boost\regex\v4\regex_search.hpp(144) : see declaration of 'boost::regex_search'
1>s:\libs\saigcontrols\strlib\sgstr_parse.cpp(628) : error C2782: 'bool boost::regex_search(BidiIterator,BidiIterator,const boost::basic_regex<chart,traits> &,boost::regex_constants::match_flag_type)' : template parameter 'BidiIterator' is ambiguousI would have though using:
const bool bstat = boost::regex\_search( \*ssource\_pos, what, re, mflags );
would resolve this but it doesn't. Boost reference is here: http://www.boost.org/doc/libs/1_33_1/libs/regex/doc/regex_search.html[^] I am not using the latest Boost release, yet.
-
The following code compiled fine on VC6, but won't on VS2008. The first param to regex_search() does not match any of the function signatures.
string::const\_iterator ssource\_pos; const boost::match\_flag\_type mflags = boost::match\_default | boost::match\_not\_dot\_newline | boost::format\_default; const boost::regex re( sre, boost::regex::perl | boost::regex::icase ); boost::match\_results what; const bool bstat = boost::regex\_search( ssource\_pos, what, re, mflags );
In VC6 it must have been happy using:
bool regex_search(const basic_string<chart,>& s,
match_results<<br mode="hold" /> typename basic_string<chart,>::const_iterator,
Allocator>& m,
const basic_regex<chart,>& e,
match_flag_type flags = match_default);but in VS2008 I get:
1>s:\libs\saigcontrols\strlib\sgstr_parse.cpp(628) : error C2780: 'bool boost::regex_search(const std::basic_string<chart,st,sa> &,const boost::basic_regex<chart,traits> &,boost::regex_constants::match_flag_type)' : expects 3 arguments - 4 provided
1> s:\libs\boost_1_33_1\boost\regex\v4\regex_search.hpp(152) : see declaration of 'boost::regex_search'
1>s:\libs\saigcontrols\strlib\sgstr_parse.cpp(628) : error C2780: 'bool boost::regex_search(const charT *,const boost::basic_regex<chart,traits> &,boost::regex_constants::match_flag_type)' : expects 3 arguments - 4 provided
1> s:\libs\boost_1_33_1\boost\regex\v4\regex_search.hpp(144) : see declaration of 'boost::regex_search'
1>s:\libs\saigcontrols\strlib\sgstr_parse.cpp(628) : error C2782: 'bool boost::regex_search(BidiIterator,BidiIterator,const boost::basic_regex<chart,traits> &,boost::regex_constants::match_flag_type)' : template parameter 'BidiIterator' is ambiguousI would have though using:
const bool bstat = boost::regex\_search( \*ssource\_pos, what, re, mflags );
would resolve this but it doesn't. Boost reference is here: http://www.boost.org/doc/libs/1_33_1/libs/regex/doc/regex_search.html[^] I am not using the latest Boost release, yet.
Why not
bool bstat = boost::regex_search(ssource_pos.begin(), ssource_pos.end(), what, re, mflags)
?Voici, la jeune femme est enceinte, elle va enfanter un fils et elle lui donnera le nom d'Emmanuel.
-
Why not
bool bstat = boost::regex_search(ssource_pos.begin(), ssource_pos.end(), what, re, mflags)
?Voici, la jeune femme est enceinte, elle va enfanter un fils et elle lui donnera le nom d'Emmanuel.
Andy Moore wrote:
Why not bool bstat = boost::regex_search(ssource_pos.begin(), ssource_pos.end(), what, re, mflags)?
That is what I finished up doing but I was/am interested in knowing how I could resolve the original issue. ie. get a std::string from a string::const_iterator.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
-
Andy Moore wrote:
Why not bool bstat = boost::regex_search(ssource_pos.begin(), ssource_pos.end(), what, re, mflags)?
That is what I finished up doing but I was/am interested in knowing how I could resolve the original issue. ie. get a std::string from a string::const_iterator.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
Neville Franks wrote:
I was/am interested in knowing how I could resolve the original issue. ie. get a std::string from a string::const_iterator.
You can't. You can construct a copy of the string from an iterator pair, but technically, there's no way to deduce the string endpoints from a single iterator. The reason it worked on VC6 is because VC6 std::string iterators were char pointers. Although (strictly), std::strings don't have to be stored as null-terminated strings, in practise they are, so a std::string could be constructed usng a single std::string iterator.
-
Neville Franks wrote:
I was/am interested in knowing how I could resolve the original issue. ie. get a std::string from a string::const_iterator.
You can't. You can construct a copy of the string from an iterator pair, but technically, there's no way to deduce the string endpoints from a single iterator. The reason it worked on VC6 is because VC6 std::string iterators were char pointers. Although (strictly), std::strings don't have to be stored as null-terminated strings, in practise they are, so a std::string could be constructed usng a single std::string iterator.
Thanks Stuart, that's what I was looking for. Head scratching can stop now. I've just started moving a big project from VC6 to VS2008 and was expecting various issues to confront me.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com