variadic args
Bill Baxter
dnewsgroup at billbaxter.com
Thu Dec 7 16:48:18 PST 2006
Kirk McDonald wrote:
> novice2 wrote:
>> can i pass variadig arguments from one function to other?
>> siomething like:
>>
>> void func1(...)
>> {
>> func2(...);
>> }
>>
>> is it still not possible?
>>
>> (sorry, i was asked this some time ago. but now i see array
>> literals are mnaked and other good changes - may be this question
>> changed too.)
>
> The new variadic templates make this easy:
>
> void func1(T ...)(T t) {
> func2(t);
> }
>
... if you don't mind compile-time variadic behavior. I.e. can't pass
func1 around as a function pointer, can't make it a polymorphic member
in a class, you don't mind different code being generated for every
place you call it, don't mind making the function's definition available
as source code ... etc.
But if you are ok with that then, yeh, variadic templates work quite nicely.
--bb
More information about the Digitalmars-d-learn
mailing list