Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

STL11: Magic && Secrets

Download

Right click “Save as…”

Slides (view online)

The C++ Standard Library expanded and evolved massively between C++98/03 and C++11.  It's easy to forget the magnitude of these changes, because they happened gradually and sometimes invisibly.  Some things (like shared_ptr, regex, and function) were developed in Boost in the early 2000s, before making their way into TR1 in 2005 and then C++11.  Other things, like container move semantics, automatically improve programs without human intervention.  Sometimes I can hardly believe that programmers used to live without non-intrusive deterministically reference-counted smart pointers!  We are fortunate to live in such an advanced and enlightened age.

In this presentation, I'll explore how some of the C++11 Standard Library's magic works, including how the Standardization Committee fixed pair's constructors (I bet you think that pair is the simplest type in the world - ha! wrong!) and how I saved a million zillion bytes of memory across all the programs using VC10+'s make_shared<T>().

Oh, and I will also reveal a secret that has never been announced before.

Follow the Discussion

  • how do i watch this session on-demand?

  • Because of my office, I could not watch yesterday's event. I would appreciate if you share the link to watch this event. Thank you !

  • CharlesCharles Welcome Change

    , gotcha13 wrote

    how do i watch this session on-demand?

    Press play Smiley

    C

  • At 35:12, you start talking about move semantics in the context of the flip function taking a string by value, but there are no move semantics involved here. Since the arguments are const char arrays, the string variable s is simply initialized by the constructor string(const char*), as it always has been.

  • STLSTL

    I was taking shortcuts - move semantics would have been involved if the sources were str + "stuff" - but the point still holds.

    Compare:

    flip(const string& s) { string ret(s); // #1, reverse and return ret

    versus:

    flip(string s) { // #2, reverse and return s

    Given flip("meow"), #1 creates a temporary string, binds the const reference s to it, then (unnecessarily!) copies it into ret. #2 constructs s from "meow", as you mentioned, then flips and move-returns it.

    So, #2 made sense even in C++98/03, and it plays nice with move semantics.

  • Xeoc9xeo Sanity is just a mask

    Great talk, it's always a joy to hear you talking! I hope you'll have a little bit more time for your Advanced STL series once VS11 is out.

    Then, any particular reason that nearly every slide was titled with a TVTrope? Smiley

    (Also, can we get access to these slides?)

  • someonesomeone

    What are cars, putters and stoods??!

  • C64C64

    , STL wrote

    Compare:

    flip(const string& s) { string ret(s); // #1, reverse and return ret

    versus:

    flip(string s) { // #2, reverse and return s

    Given flip("meow"), #1 creates a temporary string, binds the const reference s to it, then (unnecessarily!) copies it into ret. #2 constructs s from "meow", as you mentioned, then flips and move-returns it.

    So, #2 made sense even in C++98/03, and it plays nice with move semantics.

    So, when we have a C++ class X and we want to modify a copy of it inside a function/method, does it make sense (also in C++98/03) to always use signature like your #2? i.e.

    DoSomething( X x )

    instead of the more usual DoSomething(const X &) ?

    Thanks.

     

  • DanDan

    Audio, at least on the "High Quality MP4", is out of sync with the video. Either that or STL can add ventriloquism to his already impressive list of skills and credentials ;-)

    Haven't downloaded the other qualities, maybe it's just the HQ MP4. FWIW, I downloaded the other videos, this seems to be the only one that's buggered.

    Thanks for making the videos & slides for the talks available, much appreciated. The only problem is that now I regret even more not being able to attend :-(

  • DanDan

    By "downloaded the other videos", I meant the other talks, sorry if that wasn't clear...

  • CharlesCharles Welcome Change

    By "downloaded the other videos", I meant the other talks, sorry if that wasn't clear...

    Thank you, Dan. I noticed that too (when the file was intitially released). It was re-encoded to hopefully fix the HQ MP4 audio sync issue. Looks like it didn't work Sad

    We'll figure it out.

    C

  • STLSTL

    c9xeo> Great talk, it's always a joy to hear you talking!

    Thanks!

    c9xeo> I hope you'll have a little bit more time for your Advanced STL series once VS11 is out.

    Me too. You can think of this as "Advanced STL, Part Infinity" for the time being. :->

    c9xeo> Then, any particular reason that nearly every slide was titled with a TVTrope?

    I came up with "Twenty Minutes Into The Future" and "The Reveal" first, and I liked them so much, I had to follow the pattern. :->

    c9xeo> (Also, can we get access to these slides?)

    The links are above: "Slides (view online)"

    someone> What are cars, putters and stoods??!

    I pronounce "char", "ptr", and "std" as "care" (it's the prefix of "character"), "putter", and "stood".

    C64> So, when we have a C++ class X and we want to modify a copy of it inside a function/method, does it make sense (also in C++98/03) to always use signature like your #2?

    Yes. It's sometimes better, and never worse. The advantage increases in C++11, but is present in C++98/03.

  • STLSTL

    (never mind)

  • JonJon

    As always i enjoy reading this awesome content, i hope you can find as much enjoyable content from me in return.

  • Xeoc9xeo Sanity is just a mask

    > Me too. You can think of this as "Advanced STL, Part Infinity" for the time being. :->

    Heh, topic suggestion: Template meta programming! With things like Expression SFINAE, writing ones own type traits (like how to find out if a class has a certain member function), like you did in part 5 of Advanced STL.

    Maybe also about constexpr? But that isn't implemented in VS, right? Sad

    Hmm, what else... I'll think about it some more and report back. Smiley

    Edit: Oooh, another idea! I know this doesn't really count as STL, since they don't belong in that subpart of the library, but what about IOstreams? Especially the streambufs, locales, facets, codecvt stuff. As far as I know, there's only one real book on IOstreams, and it's from 2000 (IIRC). And personally, I think IOstreams are one of the more advanced topics, if you go beyond simple streaming to existing streams. Smiley

  • Hi guys,

    I just wanna ask you guys, what question did Bjarne Stroustrup ask during the last few minutes? I didn't hear it clearly 

  • STLSTL

     

    c9xeo> Heh, topic suggestion: Template meta programming!
     
    I am definitely thinking I'll do a "Core C++" series, including TMP but also template argument deduction, overload resolution, name lookup, etc.
     
    > With things like Expression SFINAE
     
    That's not yet supported by VC in full generality, but Herb announced post-VC11 "out of band" releases, where new features will appear. 
     
    > Maybe also about constexpr? But that isn't implemented in VS, right?
     
    Correct. constexpr is a very, very big feature. 
     
    > what about IOstreams? 
     
    iostreams fills me with dread and loathing. Maintaining the stuff is just about all I can handle. Tongue Out
     
    haohaolee> I just wanna ask you guys, what question did Bjarne Stroustrup ask during the last few minutes?
     
    IIRC, whether I would define NULL to be nullptr. I said yes if I had a time machine, no otherwise. 

  • Xeoc9xeo Sanity is just a mask

    > I am definitely thinking I'll do a "Core C++" series

    Yes, please!

    > iostreams fills me with dread and loathing. Maintaining the stuff is just about all I can handle.

    Then make it a "Bash the IOstreams" session? Smiley Tell us what's so horrible about them!

  • @STL

    Thanks

  • Here is the future sample code:

    string flip(string s) {   

    reverse(begin(s), end(s));

     return s;

    }

    vector<future<string>> v;

    v.push_back(async( [] {return flip(" ,gnol oS"); }));

    v.push_back(async( [] {return flip(" dlrow"); }));

    v.push_back(async( [] {return flip("\n.ti wonk ew sa"); }));

    for(auto& e : v) { cout << e.get(); }

     

    Thanks,

    Comet

    purr more, hiss less

  • CharlesCharles Welcome Change

    , c9xeo wrote

    > I am definitely thinking I'll do a "Core C++" series

    Yes, please!

    > iostreams fills me with dread and loathing. Maintaining the stuff is just about all I can handle.

    Then make it a "Bash the IOstreams" session? Smiley Tell us what's so horrible about them!

    The Core C++ series has begun: http://channel9.msdn.com/Shows/Going+Deep/Stephan-T-Lavavej-Core-C-1-of-n

    STL rocks!
    C

  • lililili

    What is matter your eyes?

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.