Fabian Deutsch wrote: [...]
Copy-n-pasting another way from the the tutorial to initialize a struct
type:
Color c3 = Color() {
red = 0.5,
green = 0.5,
blue = 1.0
};
This is really creating a temporary and then initialising c3 via
assignment, which isn't quite what I was looking for. If you look at the
generated code and compare the above with:
Color c3 = { 0.5, 0.5, 1.0 };
...you can see that the code generated by this syntax avoids the extra
copy. It seems surprising to me that the Type() { initialiser } syntax
supports designated initialisers while the Type t = { initialiser }
syntax doesn't.
--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup
Attachment:
signature.asc
Description: OpenPGP digital signature