Live data from Hacker News

C++ value category cheat-sheet [pdf]

github.com

31–40 of 41 posts

Re: C++ value category cheat-sheet [pdf]

#31

I think the biggest issue in C++ is that you don't have to understand this whole mess to be productive in it. This is also perhaps its greatest strength. Where you have Rust which won't even compile a basic toy program without demonstrating a full understanding of its Ownership model.

Which is it? C++ programmers are smart enough to not need the features that Rust provides? Or C++ programmers aren't smart enough to learn basic concepts that they should already know considering their compiler doesn't help them write correct code?

Re: C++ value category cheat-sheet [pdf]

#32
post #27

Earlier quoted context omitted.

Never give advice without telling why, because it's very likely that people will forget it if they don't understand your advice.

Ok. auto i{42}; // std::initializer_list

But why is that bad?

Re: C++ value category cheat-sheet [pdf]

#33
post #27

Earlier quoted context omitted.

Never give advice without telling why, because it's very likely that people will forget it if they don't understand your advice.

Ok. auto i{42}; // std::initializer_list

No longer applies with c++17

Re: C++ value category cheat-sheet [pdf]

#34

Earlier quoted context omitted.

Ok. auto i{42}; // std::initializer_list

But why is that bad?

Because `i` isn't an int, it's an initializer_list, and you almost never want to actually create an initializer_list instead of an int? Seems pretty understandable to me.

Re: C++ value category cheat-sheet [pdf]

#36
post #26
post #5

A comment on the document's design: The low contrast of light gray text on yellow background makes it difficult to read. Black text on white, or dark gray text on white is perfectly acceptable. Another drawback of colored backgrounds is that readers wanting to print out the pdf will consume ink/toner to render the non-white background.

Relevant: http://contrastrebellion.com

That site is great but it leaves out something else that is very important. Color blind people often have trouble with seeing colors that are "near" to each other in color-space.

I'm not a PhD in Colorology but choosing higher contrast colors completely eliminates that problem I think. It's an easy fix that opens up many new markets to your software.

Re: C++ value category cheat-sheet [pdf]

#37
post #13

Earlier quoted context omitted.

This might answer that https://herbsutter.com/2008/01/01/gotw-88-a-candidate-for-th... I think this is similar to the std::max/std::min stuff

No, that post refers to the lifetime of temporaries held by local reference variables. My question is about temporaries created to pass reference parameters to a function. Is the lifetime of that temporary the BODY of the function? The full expression that calls the function? The enclosing scope of that full expression? (for the record, VS2017 does the latter)

[deleted]

Re: C++ value category cheat-sheet [pdf]

#40

Softer entry to the whole concept of lvalues/rvalues in general: http://eli.thegreenplace.net/2011/12/15/understanding-lvalue...

And of course there's Strachey's Fundamental Concepts in Programming Languages (1967), which introduced the LValue/RValue distinction. It is very readable and relevant today.

http://www.cs.cmu.edu/~crary/819-f09/Strachey67.pdf

Post reply on HN