-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature suggestion: automatic generation of constructor #447
Comments
Nice idea. There are a couple potential issues with the idea as suggested:
struct Person {
string firstname;
string lastname;
void operator init=auto;
Person[] children;
void operator init=auto;
} might have two "default" constructors, one of which takes struct Info {
string name;
void addname(string s) { name += s; }
arrowbar3 ab;
void operator init = auto;
} Presumably we want to set struct Info {
string name;
void addname(string s) { name += s; }
bool ab(picture, path3, material, margin3, light, light);
void operator init = auto;
} And in this iteration, it's less clear that One idea to solve the latter issue would be that the constructor should reference those variables that are not explicitly initialized. So for instance, in struct Person {
string firstname;
string lastname = 'Smith';
void operator init = auto;
}
None of this is to say that the idea cannot or should not be implemented in some form, only that careful thought is required. One final note: While suggested improvements are always appreciated, please do keep in mind that many improvements can sit around for years before anyone gets around to implementing them (if ever), even if the improvement is straightforward and everyone agrees on what it ought to be. |
For example, currently in order to define a constructor we need to
Or a bit shorter:
But I think that can be automatically generated by something like the following (new syntax)
Inspired by
=default;
and=delete;
syntax from C++.The text was updated successfully, but these errors were encountered: