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

Поділитися
Вставка
  • Опубліковано 20 гру 2024
  • CppCon.org
    -
    Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/Cpp...
    -
    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 cppbestpractice....
    I'm available for contracting and onsite training.
    -
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    *-----*
    Register Now For CppCon 2022: cppcon.org/reg...
    *-----*

КОМЕНТАРІ • 48

  • @jankodedic3130
    @jankodedic3130 7 років тому +65

    Great talk by JSON, as always!

  • @zhivkobogdanov2845
    @zhivkobogdanov2845 3 роки тому +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.

  • @thelatestartosrs
    @thelatestartosrs 3 роки тому

    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 7 років тому +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 7 років тому +4

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

    • @AJlex100500
      @AJlex100500 7 років тому +1

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

  •  4 роки тому +3

    if constexpr is pure happiness.

  • @traxooza
    @traxooza 3 роки тому

    15:48 How about noexcept_cast ? :D

  • @sonulohani
    @sonulohani 7 років тому +14

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

  • @Jimmy9Bazooka
    @Jimmy9Bazooka 6 років тому

    @ 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 4 роки тому

      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.

  • @nmmm2000
    @nmmm2000 7 років тому +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 7 років тому +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 7 років тому

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

    • @timoleksii
      @timoleksii 5 років тому

      @@nmmm2000 have you considered using devtoolset?

    • @seditt5146
      @seditt5146 5 років тому

      @@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

  • @KulaGGin
    @KulaGGin 2 роки тому

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

  • @yackawaytube
    @yackawaytube 5 років тому +1

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

  • @fvzaur
    @fvzaur 5 років тому

    gotta watch this one

  • @joe-ti8rz
    @joe-ti8rz 6 років тому

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

  • @crystalgames
    @crystalgames 6 років тому

    thanks)

  • @UneededStudios
    @UneededStudios 6 років тому

    namespace ParentNamespace:: {} ? @ 9:00

  • @karolyhorvath7624
    @karolyhorvath7624 6 років тому

    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 6 років тому +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 6 років тому

      see what?

    • @JohnLudlow
      @JohnLudlow 6 років тому +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 UA-cam and URL highlighting

    • @karolyhorvath7624
      @karolyhorvath7624 6 років тому

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

    • @JohnLudlow
      @JohnLudlow 6 років тому +3

      Uhm, Ok

  • @maru7768
    @maru7768 6 років тому

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