Advertisement
WeltEnSTurm

dynamic tostring + formatting

Oct 19th, 2012
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.39 KB | None | 0 0
  1. static dchar formatChar = '%';
  2.  
  3.  
  4. string tostring(Args...)(Args args){
  5.     static if(args.length > 0){
  6.         static if(is(args[0] == string) && args[0].find(formatChar) > -1){
  7.             int i = args[0].find(formatChar);
  8.             return args[0][0..i] ~ to!string(args[1]) ~ tostring(args[0][i+1..$], args[2..$]);
  9.         }else{
  10.             return to!string(args[0]) ~ tostring(args[1..$]);
  11.         }
  12.     }else{
  13.         return "";
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement