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...
*-----*
Great talk by JSON, as always!
constexpr JSON noexcept
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.
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;`
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?
string_view is not implicity-convertible to string, but the initializer list can call explicit constructors.
Thanks for the answer, I didn't realize string had an explicit constructor from string_view.
if constexpr is pure happiness.
15:48 How about noexcept_cast ? :D
Thanks to this channel for sharing such an awesome presentations. Very much appreciated.
@ 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.
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.
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
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
on centos 7, there is gcc 4.8, nothing new, unless you compile it yourself.
@@nmmm2000 have you considered using devtoolset?
@@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
"By your leave, Mr. Turner"🏴☠
I understand every single slide here, but I am not a C++ Jedi yet
gotta watch this one
Perspective. I understand more of The game of thrones than of this talk. Il still win.
thanks)
namespace ParentNamespace:: {} ? @ 9:00
its a nested namespace
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.
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#...)
see what?
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
I don't see any similar feature. Either be very specific, or (preferably) leave me out of this nonsense.
Uhm, Ok
Drinking game! Have a shot every time he says "thing"