Boost logo

Boost Users :

Subject: Re: [Boost-users] split_iterator not working with a reference to const std::string
From: Jeff Flinn (Jeffrey.Flinn_at_[hidden])
Date: 2012-04-09 07:59:20


On 4/9/2012 4:25 AM, asif saeed wrote:
> Hi,
>
> Here is my code:
>
> struct CharIterator
> {
> CharIterator( const std::string &s, char_t const *delimiters)
> :s_(s),
> begin_(boost::algorithm::split_iterator<std::string::iterator>(s,
> boost::token_finder(boost::is_any_of(delimiters),
> boost::token_compress_off))),
> end_(boost::algorithm::split_iterator<std::string::iterator>()),
> i_(begin_)
> {
> }
>
> const std::string s_&;
> boost::algorithm::split_iterator<std::string::iterator> begin_, end_, i_;
> };
>
>
> The compile gives me an error on parameter 1 of the above constructor.
> It compiles fine if I change "const std::string &s" to "std::string s" -
> that is, pass by value. I just want to store a reference to a string.
> Could you help me on this?

Try using std::string::const_iterator.

Jeff


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