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
morestl: add examples for std::optional, any, variant #79
Conversation
004cfc9
to
879cfb7
Compare
a06b21b
to
a407cdb
Compare
Signed-off-by: Abhishek Lekshmanan <abhishek.lekshmanan@cern.ch>
a407cdb
to
e844f5b
Compare
Signed-off-by: Abhishek Lekshmanan <abhishek.lekshmanan@cern.ch>
Signed-off-by: Abhishek Lekshmanan <abhishek.lekshmanan@cern.ch>
Signed-off-by: Abhishek Lekshmanan <abhishek.lekshmanan@cern.ch>
Signed-off-by: Abhishek Lekshmanan <abhishek.lekshmanan@cern.ch>
bbc6593
to
110f756
Compare
Signed-off-by: Abhishek Lekshmanan <abhishek.lekshmanan@cern.ch>
a02f907
to
d3f3914
Compare
Signed-off-by: Abhishek Lekshmanan <abhishek.lekshmanan@cern.ch>
d3f3914
to
c862e8f
Compare
Added slides on |
Now that the different slides are written, I feel like the original one should be dropped and the content distributed into the different sections. It feels odd to start with it, then switch to string_view and comes back to the 3 items, one by one. |
This makes sense, also makes it easy slide estate planning wise so I could mostly go for one slide explaining the item and the next one with the program example |
Co-authored-by: Stephan Hageboeck <stephan.hageboeck@cern.ch>
Co-authored-by: Stephan Hageboeck <stephan.hageboeck@cern.ch>
@theanalyst This is almost ready to be merged, but if you do not mind, I would go for dropping the introduction slide and merge it in the others. I can do it myself if you agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one formatting thing and one optional line break. Otherwise, the output of the program would look a bit complicated.
Yes sure go ahead, sorry things got a bit too busy after the vacation |
Ok, will do. I was also busy until now, so starting only today. One question I have though. The code presented for std::any looks wrong to me : if (Monster *m = std::any_cast<Monster>(&e)) {
m->take_hit(this->damage);
} else if (Orc *o = std::any_cast<Orc>(&e)) {
o->take_hit(this->damage*0.5);
} else if (Cat *c = std::any_cast<Cat>(&e)) {//No! it assumes |
Actually, only the reference and universal reference versions will throw @sponce. The pointer versions do return |
On now I've seen the little "(1-3)" in the cpp reference ! Thanks @hageboeck for being more awake than I was. I anyway would not take an example using pointers. After all we want to teach people to drop them everywhere. |
So I've created a new version of this one in #89 (could not push to @theanalyst' s branch). I've changed the examples for any and if constexpr. @hageboeck if you could review, would be appreciated |
Yes indeed, that was a mistake, should've been |
Draft WIP #69 PR ...don't have a full tex system currently so will be (ab)using the CI for a bit while I still make up other examples...