Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-08-16 20:10:49


Ross Smith wrote:
> I think you've misunderstood the way the output iterator version was
> intended to work. I was the one who originally posted the idea, and my
> suggested signature and usage look like this:
>
> template <typename OutputIterator>
> OutputIterator split(const std::string& source,
> OutputIterator target,
> const std::string& delimiters = "
> \f\n\r\t");
>
> std::string sentence("foo bar zap");
> std::vector<std::string> words;
> split(sentence, std::back_inserter(words));

With "sequence arguments support" you can do even better:

    boost::iterator_range<boost::tokenizer<>::iterator>
    split(std::string const& source, std::string const& delimiters =
"\f\n\r\t");
    
    //...
    std::string sentence("foo bar zap");
    boost::vector<std::string> words(boost::split(sentence));

Aleksey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk