Compile time string parse

Jarrett Billingsley jarrett.billingsley at gmail.com
Tue Mar 17 08:35:12 PDT 2009


On Tue, Mar 17, 2009 at 11:32 AM, Jarrett Billingsley
<jarrett.billingsley at gmail.com> wrote:

Sigh, I'll get it eventually.

template Atoi(string s)
{
	static if(s.length == 1)
		enum int Atoi = s[$ - 1] - '0';
	else
		enum int Atoi = 10 * Atoi!(s[0 .. $ - 1]) + (s[$ - 1] - '0');
}


More information about the Digitalmars-d-learn mailing list