CppCon 2017: Jason Turner “Practical C++17”

Sdílet
Vložit
  • čas přidán 13. 10. 2017
  • CppCon.org
    -
    Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2017
    -
    C++17 adds many new features: structured bindings, deduction guides, if-init expressions, fold expressions, if constexpr, and enhanced constexpr support in the standard library. Each of these features are interesting, but what will be their cumulative effect on real code? We'll explore how each feature may (or may not) help in real code for enhanced readability, compile time performance and runtime performance.
    -
    Jason Turner: Developer, Trainer, Speaker
    Host of C++Weekly / jasonturner-lefticus , Co-host of CppCast cppcast.com, Co-creator and maintainer of the embedded scripting language for C++, ChaiScript chaiscript.com, and author and curator of the forkable coding standards document cppbestpractices.com.
    I'm available for contracting and onsite training.
    -
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    *-----*
    Register Now For CppCon 2022: cppcon.org/registration/
    *-----*

Komentáře • 48

  • @jankodedic3130
    @jankodedic3130 Před 6 lety +64

    Great talk by JSON, as always!

  • @zhivkobogdanov2845
    @zhivkobogdanov2845 Před 3 lety +3

    As an addition to what has been mentioned @35:40 it is also correct to move the value on return if you take the same value by rvalue reference and modify it within a function, as mentioned in another CppCon talk.

  • @sonulohani
    @sonulohani Před 6 lety +14

    Thanks to this channel for sharing such an awesome presentations. Very much appreciated.

  •  Před 4 lety +3

    if constexpr is pure happiness.

  • @fvzaur
    @fvzaur Před 5 lety

    gotta watch this one

  • @thelatestartosrs
    @thelatestartosrs Před 2 lety

    37:40 IMO it is a flaw right? it stops NRVO as he explained before and the simple way to fix it (in the language) is to replace instances of usage of the binding variable names with the binding value.
    like instead of
    `auto& value = e.second; f(value); return value;`
    just do
    `f(e.second); return e.second;`

  • @AJlex100500
    @AJlex100500 Před 6 lety +1

    I don't understand why the code at 47:51 should compile. Afaik std::string_view is not convertible to std::string, therefore constructing m_string from sv is not possible. So what gives?

    • @SebastianHasler
      @SebastianHasler Před 6 lety +4

      string_view is not implicity-convertible to string, but the initializer list can call explicit constructors.

    • @AJlex100500
      @AJlex100500 Před 6 lety +1

      Thanks for the answer, I didn't realize string had an explicit constructor from string_view.

  • @nmmm2000
    @nmmm2000 Před 6 lety +7

    Great talk, I love it. This is why I do not use C++17 yet. Second reason is lack of standard compiler support in CentOS 6

    • @llothar68
      @llothar68 Před 6 lety +2

      Compiler support is pretty good. But the tools are much much slower to pick up then the naked compiler.
      std::string_view on gcc is still crashing gdb

    • @nmmm2000
      @nmmm2000 Před 6 lety

      on centos 7, there is gcc 4.8, nothing new, unless you compile it yourself.

    • @timoleksii
      @timoleksii Před 4 lety

      @@nmmm2000 have you considered using devtoolset?

    • @seditt5146
      @seditt5146 Před 4 lety

      @@nmmm2000 Man that is a shame, it has been two years, do you still not use C++ 17? It is great, by far the best and most stable version of C++ I have ever used. I can not express how great CTAD is for a programmer. The code looks so much cleaner as well not having to have ugly template brackets all over all templated calls

  • @crystalgames
    @crystalgames Před 6 lety

    thanks)

  • @KulaGGin
    @KulaGGin Před 2 lety

    "By your leave, Mr. Turner"🏴‍☠

  • @traxooza
    @traxooza Před 3 lety

    15:48 How about noexcept_cast ? :D

  • @Jimmy9Bazooka
    @Jimmy9Bazooka Před 5 lety

    @ 41:02 "It is doing exactly what I needed to do and is correct". Sorry, no, it's not correct. You have no unexpanded parameter pack there. "node" parameter should have been "const AST_Node_Impl*... node" for your fold expression to compile.

    • @OMGclueless
      @OMGclueless Před 3 lety

      Presumably T is a parameter pack here. Confusing because it's named "T" instead of "Ts" or something, and the template parameter definitions were chopped off in his snippet, but I think that's what's going on and in that case it's fine.

  • @joe-ti8rz
    @joe-ti8rz Před 6 lety

    Perspective. I understand more of The game of thrones than of this talk. Il still win.

  • @yackawaytube
    @yackawaytube Před 4 lety +1

    I understand every single slide here, but I am not a C++ Jedi yet

  • @karolyhorvath7624
    @karolyhorvath7624 Před 6 lety

    I honestly don't get why they added if-init. It looks like a mess and we already have braces { } to create an inner scope.

    • @JohnLudlow
      @JohnLudlow Před 6 lety +1

      I think they're following C#, though C#'s equivalent is (IMHO) cleaner - see docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/is#pattern-matching-with-is
      It's useful in a few situations, mainly for reducing the variables you have flying around your method. It wasn't that big a deal for his methods because as he said, his methods tend to be short anyway, so the scope impact is minimal. I still think it's marginally more readable with the new version because you don't have a temporary variable, but not a huge difference because the syntax is a little weird to me (though I mostly live in C#...)

    • @karolyhorvath7624
      @karolyhorvath7624 Před 6 lety

      see what?

    • @JohnLudlow
      @JohnLudlow Před 6 lety +1

      Sorry if I wasn't clear. The link points to the docs for (part of) C#'s implementation of a similar feature, which has proved useful in some situations.
      Of course, I linked to the docs for the specific case which I've used (the broader description is here: docs.microsoft.com/en-us/dotnet/csharp/pattern-matching ) and in the doc I linked to, there wasn't an anchor that led straight to the code example that would have made it make sense - you have to scroll down a little for that.
      Sorry about that
      Edit: Damn CZcams and URL highlighting

    • @karolyhorvath7624
      @karolyhorvath7624 Před 6 lety

      I don't see any similar feature. Either be very specific, or (preferably) leave me out of this nonsense.

    • @JohnLudlow
      @JohnLudlow Před 6 lety +3

      Uhm, Ok

  • @maru7768
    @maru7768 Před 5 lety

    Drinking game! Have a shot every time he says "thing"

  • @UneededStudios
    @UneededStudios Před 6 lety

    namespace ParentNamespace:: {} ? @ 9:00