Copying parameter lists verbatim

Jakob Ovrum via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 20 02:29:17 PDT 2014


On Saturday, 19 July 2014 at 17:40:01 UTC, Andrei Alexandrescu 
wrote:
> On 7/19/14, 9:36 AM, Jakob Ovrum wrote:
>> On Saturday, 19 July 2014 at 06:13:10 UTC, Manu via 
>> Digitalmars-d wrote:
>>> Anyway, does anybody know a nice tidy way to do it?
>>
>> Unfortunately the only way to create perfect forwarding 
>> functions
>> completely generically is still using an ugly string mixin that
>> generates the forwarding function. A subset of forwarding 
>> functions can
>> be created using templates and auto-ref, but of course a 
>> function
>> template has many disadvantages to a concrete function (virtual
>> functions being a good example).
>
> How can this be encapsulated as a library artifact? -- Andrei

Since the key parts of the forwarding function - the parameter 
list and attribute list - are part of the signature, the entire 
function declaration has to be mixed in. That means the function 
body has to be provided as a string argument. This tends to cause 
some seriously unreadable code. It may be a lost cause but I'm 
hoping we can amend the language to avoid that.


More information about the Digitalmars-d mailing list