Let's say I have this struct:
struct MyStruct {
int field1;
char *field2;
MyStruct(int a, char* b): field2(b) {
field1 = doStuff(a);
}
MyStruct(int a): MyStruct(a, nullptr) {}
~MyStruct();
}
As far as I know this is not an aggregate as I have some constructors.
What I want to achieve is to use the curly brace initializer in a custom way, which means using a code like this:
MyStruct x = { 1, "string" };
which implicitly calls the proper constructor (the first one in this case).
Is this possible in any way?