Printing shortest decimal form of floating point number with Mir
welkam
wwwelkam at gmail.com
Tue Jan 5 23:26:26 UTC 2021
On Tuesday, 5 January 2021 at 21:46:34 UTC, Ola Fosheim Grøstad
wrote:
> On Tuesday, 5 January 2021 at 21:43:09 UTC, welkam wrote:
>> Replace alias Bar(T) = Foo!T; with alias Bar = Foo;
>>
>> struct Foo(T) {}
>>
>> alias Bar = Foo;
>>
>> void f(T)(Bar!T x) {}
>>
>> void main() {
>> auto foo = Bar!int();
>> f(foo);
>> }
>
> The example was a reduced case. One can trivially construct
> examples where that won't work.
>
> It is very useful to create a simple alias from a complex type
> for export from a type library, then it breaks when people use
> that type library to write templated functions.
>
> People do this all the time in C++.
I reread the whole thread. You want something like this except
without mixins and to actually work.
struct Foo(T) {}
mixin template Bar(T) {
Foo!T
}
void f(T)(Foo!T x) {}
void main() {
f(mixin Bar!(int)());
}
In languages you can pass things by value, by reference or by
name. Alias works by the name passing mechanic. You can not use
alias or capture by name here because you cant get a name of
something that doesn't exist yet.
What you want is parametric generation of definition and
insertion in place. Now that's something Walter can understand.
More information about the Digitalmars-d-announce
mailing list