Something like ADL from C++?

Max Samukha maxsamukha at gmail.com
Tue Dec 3 15:48:10 UTC 2024


On Tuesday, 3 December 2024 at 11:55:50 UTC, Manu wrote:

>
> import default_serialise : serialise;
>
> void doSerialise(Things...)(void[] buffer, Things things)
> {
>   static foreach (thing; things)
>   {{
>     static if (isUserType!thing)
>     {
>       enum thingMod = getModuleForThing!thing;
>       mixin(import " ~  thingMod ~ ";");
>     }
>     serialise(buffer thing);
>   }}
> }

BTW, do you really need to create the overload set? You could 
call the right `serialize` directly if one exists in the type's 
module and fall back to the default one if it doesn't.


More information about the Digitalmars-d mailing list