Bug 3132 – std.string.split should be templated on mutable/const/immutable

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2009-07-03T07:45:00Z
Last change time
2015-06-09T01:27:58Z
Assigned to
andrei
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2009-07-03T07:45:32Z
Kind of like what was done with strip(), et al. A good signature would be something like: String[] split(String)(String s); String[] splitlines(String)(String s); String[] split(String, D)(String s, D delim);
Comment #1 by dfj1esp02 — 2009-07-07T01:45:40Z
A better reason is templating over wstring and dstring.
Comment #2 by dfj1esp02 — 2009-07-07T01:52:20Z
templating over constness is a partial solution for bug 1961
Comment #3 by schveiguy — 2009-07-08T10:59:28Z
(In reply to comment #2) > templating over constness is a partial solution for bug 1961 No. I specifically say that the template solution does not achieve what 1961 is striving for -- single implementation and guaranteed const handling of parameters. See comment #15. Conversely, 1961 would solve this bug pretty easily :P inout(T)[] split(T)(inout(T) s); (replace inout with keyword of choice used to implement 1961).
Comment #4 by dsimcha — 2009-09-03T07:56:25Z
1. You missed splitlines. 2. string[] words should be S[] words or S1[] words in split().
Comment #5 by andrei — 2009-09-03T09:14:16Z
(In reply to comment #4) > 1. You missed splitlines. > > 2. string[] words should be S[] words or S1[] words in split(). 3. I'm a chowderhead. I fixed the above and added unittests for all string widths. If there are other functions in std.string to be modified, please open a new bugzilla entry.
Comment #6 by bugzilla — 2009-10-06T02:21:16Z
Fixed dmd 2.033