variant .init value

Norm norm.rowtree at gmail.com
Thu Feb 7 07:33:50 UTC 2019


Hi,

I'm trying to use Variant in a struct and want a default init 
value like so:

---
struct S {
   Variant v = Variant(10);
}
void main() {auto s = S();}

but when I try to build this I get the following error:

dmd2/linux/bin64/../../src/phobos/std/variant.d(661): Error: 
memcpy cannot be interpreted at compile time, because it has no 
available source code
Error: cannot interpret <error> at compile time
---

I don't particularly need or want this to be available at compile 
time, I really only want the struct to have a default value when 
instantiated at runtime.

Is there a way to do this with a Variant member?

Thanks,
Norm


More information about the Digitalmars-d-learn mailing list