-
Notifications
You must be signed in to change notification settings - Fork 868
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
Use delegating constructors (C++11 feature) #1489
Comments
For consideration to pull into v4.0.0. Peter's already covered the philosophical fork with the moving vs static sphere constructor, and I prefer the choice he made, and think that right now the two constructors (single center or double center) are good as they are. I agree with everything else, and in addition would like to review a lot of our nonsense default constructors. That is instances that by default are either garbage or zombie objects. For example, our code is fine with deleting the default |
IMHO, for some of the basic types such as struct vec3
{
double data[3];
auto&& operator[](std::size_t i) const { return data[i]; }
auto&& operator[](std::size_t i) { return data[i]; }
};
int main()
{
vec3 v1;
vec3 v2{ };
std::cout << "v1 = " << v1 << '\n';
std::cout << "v2 = " << v2 << '\n';
int i1;
int i2{ };
std::cout << "i1 = " << i1 << '\n';
std::cout << "i2 = " << i2 << '\n';
vec3 v3{1, 2, 3};
std::cout << "v3 = " << v3 << '\n';
} Output:
Now |
Here is the link that demonstrates the above: https://godbolt.org/z/cq1P51z3f |
Yes, I would definitely take advantage of the modern C++ idioms in my own C++ implementation. Beyond the scope of these books, though. |
Found two places where delegating constructors helped: ray and checker_texture. In addition, this includes some minor constructor cleanup. Resolves #1489
Found two places where delegating constructors helped: ray and checker_texture. In addition, this includes some minor constructor cleanup. Resolves #1489
solid_color
already uses it. Following classes could benefit from it:checker_texture
constant_medium
ray
lambertian
diffuse_light
isotropic
Constructors of the following classes can be merged:
sphere
-- combine moving and static constructorsnoise_texture
-- default constructor results in uninitialized use of thescale
data member; combine both constructors and provide default value forscale
The text was updated successfully, but these errors were encountered: