C++ Weekly - Ep 420 - Moving From C++17 to C++20 (More constexpr!)
Vložit
- čas přidán 2. 06. 2024
- ☟☟ Awesome T-Shirts! Sponsors! Books! ☟☟
Upcoming Workshop: Understanding Object Lifetime, C++ On Sea, July 2, 2024
► cpponsea.uk/2024/sessions/und...
Upcoming Workshop: C++ Best Practices, NDC TechTown, Sept 9-10, 2024
► ndctechtown.com/workshops/c-b...
Episode details: github.com/lefticus/cpp_weekl...
T-SHIRTS AVAILABLE!
► The best C++ T-Shirts anywhere! my-store-d16a2f.creator-sprin...
WANT MORE JASON?
► My Training Classes: emptycrate.com/training.html
► Follow me on twitter: / lefticus
SUPPORT THE CHANNEL
► Patreon: / lefticus
► Github Sponsors: github.com/sponsors/lefticus
► Paypal Donation: www.paypal.com/donate/?hosted...
GET INVOLVED
► Video Idea List: github.com/lefticus/cpp_weekl...
JASON'S BOOKS
► C++23 Best Practices
Leanpub Ebook: leanpub.com/cpp23_best_practi...
► C++ Best Practices
Amazon Paperback: amzn.to/3wpAU3Z
Leanpub Ebook: leanpub.com/cppbestpractices
JASON'S PUZZLE BOOKS
► Object Lifetime Puzzlers Book 1
Amazon Paperback: amzn.to/3g6Ervj
Leanpub Ebook: leanpub.com/objectlifetimepuz...
► Object Lifetime Puzzlers Book 2
Amazon Paperback: amzn.to/3whdUDU
Leanpub Ebook: leanpub.com/objectlifetimepuz...
► Object Lifetime Puzzlers Book 3
Leanpub Ebook: leanpub.com/objectlifetimepuz...
► Copy and Reference Puzzlers Book 1
Amazon Paperback: amzn.to/3g7ZVb9
Leanpub Ebook: leanpub.com/copyandreferencep...
► Copy and Reference Puzzlers Book 2
Amazon Paperback: amzn.to/3X1LOIx
Leanpub Ebook: leanpub.com/copyandreferencep...
► Copy and Reference Puzzlers Book 3
Leanpub Ebook: leanpub.com/copyandreferencep...
► OpCode Puzzlers Book 1
Amazon Paperback: amzn.to/3KCNJg6
Leanpub Ebook: leanpub.com/opcodepuzzlers_book1
RECOMMENDED BOOKS
► Bjarne Stroustrup's A Tour of C++ (now with C++20/23!): amzn.to/3X4Wypr
AWESOME PROJECTS
► The C++ Starter Project - Gets you started with Best Practices Quickly - github.com/cpp-best-practices...
► C++ Best Practices Forkable Coding Standards - github.com/cpp-best-practices...
O'Reilly VIDEOS
► Inheritance and Polymorphism in C++ - www.oreilly.com/library/view/...
► Learning C++ Best Practices - www.oreilly.com/library/view/... - Věda a technologie
I still think it would be really interesting to compare the binary size & runtime performance of your project over the succesive upgrades!
Noted: github.com/lefticus/cpp_weekly/issues/373
Are you sure that default spaceship operator is doing the right thing?
I had the same thought.
no, it's drinking water.
I can never remember if it's doing the left thing
It's job is to do a member wise comparison in order of declaration. If it's not doing the right thing this would be a bug in the compiler, no?
Did I miss something?
@@cppweekly If it does member wise comparison than RN(6, 4) > RN(3, 2) but I'm almost sure we can find more similar issues.
I think you want to revisit the comparison operator. By using the default implementation, you are getting an order that is not mathematically correct (e.g. with this, 1/2 is less than 1/3 !).
On another note, I enjoyed this series very much, watching code morph from broken javaesque-C++ to full constexp modern C++.
Ah, ok, I see the point.
Constexpr all the things. Not really. Recently, I implemented the Triple DES encryption algorithm in C++14 constexpr (I already had AES). I took the ~2000 test cases from NESSIE project and static asserted my correctness. Compilation time is ~45 minutes and ~10 GB RAM. If I run the tests in run-time instead, it takes merely seconds to compile and run.
What if you use the "optimize for size" flag?
Are you going to do any performance benchmarks after the c++23 upgrade? I'd be curious to see the impact of constexpr & modern c++ features.
I'll make a note to do that.
Maybe I'm weird, but I'm actually really excited about UDL's. I've been working on adding that feature to my own language complete with a unit of measurement conversion module. I've been thinking of all kinds of uses for it that probably weren't intended for C++, but most certainly will be for my own language. For instance, being able to coerce a formula involving constants into a particular type. You would have to use quotes in C++, which is fine, but not as nice to use.
I have a problem with C++ 20 in VS2019 where I am deriving a template aggregate class from a base type as a simple form of a "strong type". For some reason I had to change back to C++17 to get it to compile. I'll try again after updating to a newer version of VS.
awesome
Now show the binary size :)
Noted to compare: github.com/lefticus/cpp_weekly/issues/373
hihi 420 :>)