default arguments for const ref parameters in extern C++ functions

60rntogo 60rntogo at
Mon Sep 14 18:58:44 UTC 2020

On Monday, 14 September 2020 at 17:11:59 UTC, k2aj wrote:
> AFAIK the only way to have default ref arguments is to use a 
> global variable:
> ---
> extern(C++) struct Foo
> {
>   int x;
> }
> immutable foo1 = Foo(1);
> extern(C++) void fun(const ref Foo foo = foo1);
> ---

Thanks. This appears to work, but feels like a hack. I can live 
with that, but I'm still wondering if there is a more idiomatic 
way of solving the problem.

More information about the Digitalmars-d-learn mailing list