Re: enum in template

2009-04-30 Thread bearophile
Daniel Keep: > enum defines a "manifest constant." In other words, it defines a > constant that does NOT consume any storage anywhere in the program: it > exists only at compile-time. For the original poster: this is true in D2+ only, not in D1. Bye, bearophile

Re: enum in template

2009-04-29 Thread Sam Hu
Thank you very much Daniel! For q1:clear; For q2: You are right,it should be "~" other than "-" since it is not very clear from the vidio of Walter's metaprogramming In D: http://www.vimeo.com/4333802 Thanks again. Sam

Re: enum in template

2009-04-29 Thread Daniel Keep
Sam Hu wrote: > Hello everybody! > > Convert integral value to string literal: > > template myToString(ulong n, > string suffix=n>uint.max?"UL":"U" > { > static if (n<10) > enum myToString=cast(char)(n+'0')-suffix; //q1 > else > enum myToString=.myToString!(n/10,"

enum in template

2009-04-29 Thread Sam Hu
Hello everybody! Convert integral value to string literal: template myToString(ulong n, string suffix=n>uint.max?"UL":"U" { static if (n<10) enum myToString=cast(char)(n+'0')-suffix; //q1 else enum myToString=.myToString!(n/10,"")- .myToString!(n%10,