
I find your improvements over string class interface very valuable. Is there any hope to incorporate these changes directly into basic_string in the future C++ standard? I mean it's fine we now have super_string class but the fact we have two string classes for the same thing is confusig. And if super_string is superset and better than std::string why not replace it? Tomas "Jeff Garland" <jeff@crystalclearsoftware.com> píse v diskusním príspevku news:44B194C1.8080903@crystalclearsoftware.com...
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:
http://www.crystalclearsoftware.com/libraries/super_string/index.html
Vault location:
Probably the biggest thing in this version is an immutable version using the proposed boost::const_string.
http://www.crystalclearsoftware.com/libraries/super_string/classbasic__const...
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; data.append_file("data1.txt").append_file(data2.txt);
* Type conversion with user supplied stringstream
std::ostringstream ss; s.setprecision( 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
Enjoy,
Jeff _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost