Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Initialization in modern C++ - Timur Doumler - Meeting C++ 2018

67 views
Skip to first unread message

woodb...@gmail.com

unread,
Jan 27, 2019, 2:11:14 PM1/27/19
to
I liked this talk:
https://duckduckgo.com/?q=meeting+c%2B%2B+2018&t=ffab&iax=videos&ia=videos&iai=ZfP4VAK21zc

I watched the first few minutes and the last 12 minutes or so.
He talks about going from "almost always auto" to "always auto" with
2020 C++. I think I'm still sometimes auto.


Brian
Ebenezer Enterprises
https://github.com/Ebenezer-group/onwards

Alf P. Steinbach

unread,
Jan 27, 2019, 3:54:31 PM1/27/19
to
On 27.01.2019 20:11, woodb...@gmail.com wrote:
> I liked this talk:
> https://duckduckgo.com/?q=meeting+c%2B%2B+2018&t=ffab&iax=videos&ia=videos&iai=ZfP4VAK21zc
>
> I watched the first few minutes and the last 12 minutes or so.
> He talks about going from "almost always auto" to "always auto" with
> 2020 C++. I think I'm still sometimes auto.

Some people like simple mechanical fit-all-that-they're-interested-in
conventions that they use in a social way: those who don't use that
solution are not in the in-group and can be criticized and ridiculed.
Ha, you're not using "always auto"! So it's your own fault mate!


Cheers!,

- Alf


Vir Campestris

unread,
Jan 28, 2019, 4:52:28 PM1/28/19
to
On 27/01/2019 20:54, Alf P. Steinbach wrote:
> Some people like simple mechanical fit-all-that-they're-interested-in
> conventions that they use in a social way: those who don't use that
> solution are not in the in-group and can be criticized and ridiculed.
> Ha, you're not using "always auto"! So it's your own fault mate!

I'm "almost never auto".

I don't see how code clarity can be improved by hiding the type of a
variable.

Andy

Mr Flibble

unread,
Jan 28, 2019, 4:58:22 PM1/28/19
to
Because most of the time you don't care what the type is so the type just
adds noise: auto is very easy on the eyes.

I blogged about this subject in 2014:
https://leighjohnston.wordpress.com/2014/10/13/new-c-auto-keyword-condsidered-awesome-not-harmful/

/Flibble

--
“You won’t burn in hell. But be nice anyway.” – Ricky Gervais

“I see Atheists are fighting and killing each other again, over who
doesn’t believe in any God the most. Oh, no..wait.. that never happens.” –
Ricky Gervais

"Suppose it's all true, and you walk up to the pearly gates, and are
confronted by God," Bryne asked on his show The Meaning of Life. "What
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a
world that is so full of injustice and pain. That's what I would say."

Öö Tiib

unread,
Jan 29, 2019, 6:54:55 AM1/29/19
to
Sure if it is uint32_t then replacing it with auto does help nothing.
However when it is Config config = x.getConfig() then that reads like
too much of stutter or repeating the obvious.
Other times the type is a load of "bla::blaah<blah::bla<bla,blaah>,bla<blah>>"
That would make me to typedef it to keep code readable and then you
would go to see that typedef. Just hover over auto with mouse cursor
in sane IDE to see what it is when interested, lot easier.

Rosario19

unread,
Feb 1, 2019, 2:49:18 AM2/1/19
to
i assume "generic type" == "C++ key word auto"

i never used "auto" key word, but in some other language i mature
convinction that in a function the type of variable in input can be a
generic type (the same its result... )... it is important that all
operation in function are applicabile to that argument of function and
all the type in function are ok in using with that argument of
function (even run time ok for the type in input (compiler or pheraps
interpreter set all not definite types in variables of that function
for to be ok for the argument type passed to function))...

Öö Tiib

unread,
Feb 1, 2019, 5:08:58 AM2/1/19
to
On Friday, 1 February 2019 09:49:18 UTC+2, Rosario19 wrote:
> On Mon, 28 Jan 2019 21:52:20 +0000, Vir Campestris
> <vir.cam...@invalid.invalid> wrote:
>
> >On 27/01/2019 20:54, Alf P. Steinbach wrote:
> >> Some people like simple mechanical fit-all-that-they're-interested-in
> >> conventions that they use in a social way: those who don't use that
> >> solution are not in the in-group and can be criticized and ridiculed.
> >> Ha, you're not using "always auto"! So it's your own fault mate!
> >
> >I'm "almost never auto".
> >
> >I don't see how code clarity can be improved by hiding the type of a
> >variable.
> >
> >Andy
>
> i assume "generic type" == "C++ key word auto"

From where you took that "generic type" in above text?
Usually by "generic type" we mean templates of classes.

The auto is just placeholder where we either know too
well or do not care at all what the concrete type is.
Otherwise C++ is statically typed.

auto asterisks = std::setfill('*');

What is the type of asterisks? It is concrete type but we
typically do not know and do not care what exactly.
What we care is what it does. It manipulates stream to fill
unused width with asterisks, but it can be tricky to read
that out from its type.
0 new messages