Boost logo

Boost Users :

Subject: [Boost-users] Boost::Tokenizer / "string iterators incompatible" error on Visual C++ 2010 Express - runs ok on gcc4.6.0
From: asif saeed (asif.lse2_at_[hidden])
Date: 2011-08-01 12:45:33


Hi,

The following piece of code is giving me "string iterators incompatible"
error:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <boost/tokenizer.hpp>

class Base
{
public:
typedef boost::char_separator<char> sep_type_t;
typedef boost::tokenizer<sep_type_t> tokenizer_t;

Base(std::string s) : sep_(";"),
tok_(s,sep_),
i_(tok_.begin())
{
}
std::string nextToken()
{
if (i_!=tok_.end())
return *i_++;
else
return "";
}

protected:
sep_type_t sep_;
tokenizer_t tok_;
tokenizer_t::iterator i_;
};

class Sub : public Base
{
public:
Sub(std::string s) : Base(s)
{
std::string t = nextToken();
std::string u = nextToken();
std::string v = nextToken();
}
void doSomething()
{
int x = 0;
x +=1;
}
};

int main (int argc, char **argv)
{
Sub x("ASIF;Sohail;Kaleem;Maryam;Irfan;Khurram");
x.doSomething();
return 0;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

This code is compiling and running fine on GCC 4.6.0 / Fedora 15 / 64-bit. I
hope somebody here will help me out on this.

Best regards, Asif



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net