Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2006-07-09 19:44:01

Thanks all for the discussion/suggestions on the first version. As usual
Boosters have very helpful suggestions. I've uploaded version 2 of
super_string to the vault and put an improved set of documentation online:

Vault location:

Probably the biggest thing in this version is an immutable version using the
proposed boost::const_string.

After using it a bit, it seems to me that the immutable approach is likely
viable for most applications. To see the impact, I wrote a little performance
test. On mutating operations const_super_string is clearly slower. The
benefit on non-mutating operations is minimal. However, this version is
probably not as optimized as possible and it under emphasizes allocation, so I
expect in actual practice the mutable version may better than these tests
demonstrate. Your mileage may vary.

10 trials 500000 iterations/trial
const append test --> total elapsed: 00:00:25.071687
mutable append test --> total elapsed: 00:00:21.904486

10 trials 1000000 iterations/trial
const trim test --> total elapsed: 00:00:14.977803
mutable trim test --> total elapsed: 00:00:11.693688

10 trials 100000 iterations/trial
const contains regex test --> total elapsed: 00:00:27.044718
mutable contains regex test --> total elapsed: 00:00:27.633608

10 trials 100000 iterations/trial
const split regex test --> total elapsed: 00:00:16.517079
mutable split regex test --> total elapsed: 00:00:17.582708

Other notable changes in this version:

* Make modification functions chainable -- thanks Mark Mutz
* Add append_file function -- Thx to suggestion by Pavel Vozenilek

     super_string data;

* Type conversion with user supplied stringstream

     std::ostringstream ss;
     super_string s;
     ss << std::setprecision(3);
     double dbl = 1.987654321;
     int i = 1000;
     s.append(dbl, i, i, " stuff", dbl, ss);
     //s == "1.99 1000 1000 1.99 stuff 1.99"
     //ss -- has been modified

* Add boost.format capabilities -- Thx to suggestion by Pavel Vozenilek

     super_string s;
     double d = 1.123456789;
     int i = 1000;
     s.append_formatted(d, i , d, i, "a string", "%-7.2f %-7d %-7.2f %-7d %s");
     //s == "1.12 1000 1.12 1000 a string"

* Removed all const _copy overloads in mutable string to reduce the api size.
* Add additional template overloads to support multi-append cases like double

     double d = 1.54;
     int i = 25;
     s.append("double: ", d, " is ", i); Currently up to 5 parameters



Boost list run by bdawes at, gregod at, cpdaniel at, john at