digitalmars.D.learn - About std.string.representation
- bearophile (33/33) May 05 2013 Is it possible to have a transparent (by reference)
Is it possible to have a transparent (by reference) std.string.representation? It's handy to modify the chars, like with permutations: import std.stdio: writeln; import std.range: nextPermutation; import std.string: representation; void main() { char[] perm = "abcd".dup; do { writeln(perm); } while (nextPermutation(representation(perm))); } Currently to permute them you have to use dchars: import std.stdio: writeln; import std.range: nextPermutation; void main() { dchar[] perm = "abcd"d.dup; do { writeln(perm); } while (nextPermutation(perm)); } Or to use casts and ubytes: import std.stdio: writeln; import std.range: nextPermutation; void main() { ubyte[] perm = cast(ubyte[])("abcd".dup); do { writeln(cast(char[])perm); } while (nextPermutation(perm)); } Thank you, bye, bearophile
May 05 2013