Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. STL string::const_iterator problem converting code from VC6 to VS2008.

STL string::const_iterator problem converting code from VC6 to VS2008.

Scheduled Pinned Locked Moved ATL / WTL / STL
c++regexhelpperlhtml
5 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Neville Franks
    wrote on last edited by
    #1

    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 ambiguous

    I 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.

    A 1 Reply Last reply
    0
    • N Neville Franks

      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 ambiguous

      I 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.

      A Offline
      A Offline
      Andy Moore
      wrote on last edited by
      #2

      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.

      N 1 Reply Last reply
      0
      • A Andy Moore

        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.

        N Offline
        N Offline
        Neville Franks
        wrote on last edited by
        #3

        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

        S 1 Reply Last reply
        0
        • N Neville Franks

          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

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          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.

          N 1 Reply Last reply
          0
          • S Stuart Dootson

            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.

            N Offline
            N Offline
            Neville Franks
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups