Thanks everyone for the replies! I just thought it was weird that
implicit construction is seemingly supported when directly
initialising a struct but not in any other case. I guess it's
because it's clearly less ambiguous.
On Thursday, 1 August 2024 at 13:07:09 UTC, Lance Bachmeier wrote:
F
This code works:
```d
struct None {}
struct Option(T) {
bool hasSome;
T value;
this(None) {}
this(T v) {
hasSome = true;
value = v;
}
}
Option!int a = 123;// automatically constructs an Option!int
from a bare int
Option!int b = None(); // same as abov
Hello,
I’ve got this piece of code:
---
import std.stdio;
void test(alias fn1, alias fn2)()
{
fn1();
fn2();
}
struct Foo
{
void foo()
{
test!(bar, baz);
}
void bar()
{}
void baz()
{}
}
---
If I try to compile it, dmd complains, which I guess makes