April 21, 2005 [variadic] not typesafe | ||||
---|---|---|---|---|
| ||||
<docs href="http://www.digitalmars.com/d/function.html#variadic> _arguments gives the number of arguments and the type of each, enabling the creation of typesafe variadic functions. </docs> But the assertion is not thrown here: <code> import std.stdio, std.stdarg; template t(T){ T t(...){ assert( _arguments[ 0] == typeid( T)); return va_arg!(T)(_argptr); } } void main(){ writefln( t!(int delegate())(delegate real(){ return 1.1L;})()); } </code> |
April 21, 2005 Re: [variadic] not typesafe | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Manfred Nowak schrieb am Thu, 21 Apr 2005 01:08:09 +0000 (UTC): ><docs href="http://www.digitalmars.com/d/function.html#variadic> > _arguments gives the number of arguments and the type of each, enabling the creation of typesafe variadic functions. ></docs> > > But the assertion is not thrown here: > ><code> > import std.stdio, std.stdarg; > template t(T){ > T t(...){ > assert( _arguments[ 0] == typeid( T)); > return va_arg!(T)(_argptr); > } > } > > void main(){ > writefln( t!(int delegate())(delegate real(){ return 1.1L;})()); > } ></code> Added to DStress as http://dstress.kuehne.cn/run/variadic_argument_04.d http://dstress.kuehne.cn/run/variadic_argument_05.d Thomas - - Fejagd, cut those Bugs! http://fejagd.kuehne.cn -----BEGIN PGP SIGNATURE----- iD8DBQFCZzzM3w+/yD4P9tIRAky9AJ9w0jOsYzOlG+iKchwADHQvmuv6dgCgytGj edhO0xrNYzzt444YZn6rWHk= =C+PZ -----END PGP SIGNATURE----- |
Copyright © 1999-2021 by the D Language Foundation