Thread overview | |||||
---|---|---|---|---|---|
|
September 06, 2011 Default argument for template tuple function parameter | ||||
---|---|---|---|---|
| ||||
AddressInfo[] getAddressInfo(T...)(string node, string service = null, T options)
DMD complains: "default argument expected for options".
What's the syntax for an empty tuple?
--
Best regards,
Vladimir mailto:vladimir@thecybershadow.net
|
September 06, 2011 Re: Default argument for template tuple function parameter | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir Panteleev | On 09/06/2011 01:01 PM, Vladimir Panteleev wrote: > AddressInfo[] getAddressInfo(T...)(string node, string service = null, T > options) TypeTuple!() emptyTuple; AddressInfo[] getAddressInfo(T...)(string node, string service = null, T options=emptyTuple) {} Error: cannot implicitly convert expression (tuple()) of type () to () And this smells like a compiler bug. Workaround: AddressInfo[] getAddressInfo()(string node){return getAddressInfo(node,cast(string)null);} AddressInfo[] getAddressInfo(T...)(string node, string service, T options); |
September 06, 2011 Re: Default argument for template tuple function parameter | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On Tue, 06 Sep 2011 14:37:55 +0300, Timon Gehr <timon.gehr@gmx.ch> wrote: > Workaround: > > AddressInfo[] getAddressInfo()(string node){return getAddressInfo(node,cast(string)null);} > AddressInfo[] getAddressInfo(T...)(string node, string service, T options); Thanks, I tried this at first as well, but was turned off by having to cast null to string. In the end I just made the string parameter part of the variadic tuple. > And this smells like a compiler bug. Posted http://d.puremagic.com/issues/show_bug.cgi?id=6613. -- Best regards, Vladimir mailto:vladimir@thecybershadow.net |
Copyright © 1999-2021 by the D Language Foundation