Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2006-07-03 22:40:25


Shunsuke Sogame wrote:
> Jeff Garland wrote:
>
> Apart from optimization, the future (under range proposal)
> 'to_upper' might be:
>
> std::vector<char> const rng;
> std::string dst(rng|to_upper);

Sorta hard for me to anticipate the future ;-) Anyway, I assume rng can be an
std::string as well?

> The following is possible today:
>
> std::string dst = range_construct(rng|to_upper);
> range_copy(rng|to_upper|to_lower|to_upper, dst);
>
> Note that '|to_upper' is lazy.

I have no idea what this code does? Construct a range from chars that have
been upper-cased and write it into dst. Then copy the rng to while converting
it to upper, then lower, then upper? This one isn't winning me over with code
clarity...

> Well, IMHO, I prefer free-functions for another readability:
>
> ::CString rng;
> boost::to_upper(rng);
>
> std::vector<char> rng;
> boost::to_upper(rng);
>
> super_string str;
> str.to_upper(); // !

In the zero/one argument case there's no significant advantage. So I'll
repeat this case again:

     std::string s1("foo");
     std::string s2("bar);
     std::string s3("foo");
     //The next line makes me go read the docs again, every time
     replace_all(s1,s2,s3); //which string is modified exactly?
or
     s1.replace_all(s2, s3); //obvious which string is modified here

Of course, you want to be able to work consistently so you have to pull along
the functions with less arguments too.

Jeff


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