Skip to content
0:00 / 0:00

#constexpr#c++20#compilerexplorer

C++ Weekly - Ep 188 - C++20's `constexpr` `new` Support

C++ Weekly With Jason Turner

130K subscribers • 2 videos on Hallway

YouTube

Advanced. Deep dive for people who know the field.

14K views7 years ago1 recommendation

Programming languagesSystems programmingC++Memory management

Jason Turner explains how C++20 introduces support for dynamic memory allocation using new inside constexpr functions.

☟☟ Awesome T-Shirts! Sponsors! Books! ☟☟ C++ Best Practices Workshops Near You: Preview: youtu.be/Ipr6ntCAm9A Sep 12-13 (Aurora, CO): cppcon.org/class-2026-best-practices/ Sep 21-22 (Kongsberg, NO): ndctechtown.com/tickets Oct 14 (Breda, NL): cppunderthesea.nl/#workshops The code: godbolt.org/z/TnEd6nj7W T-SHIRTS AVAILABLE! ► The best C++ T-Shirts anywhere! jason-turner-shop.fourthwall.com/ WANT MORE JASON? ► My Training Classes: emptycrate.com/training.html ► Follow me on twitter: twitter.com/lefticus SUPPORT THE CHANNEL ► Patreon: patreon.com/lefticus ► Github Sponsors: github.com/sponsors/lefticus ► Paypal Donation: paypal.com/donate/?hosted_button_id=PQ4A2V6ZZFQEU GET INVOLVED ► Video Idea List: github.com/lefticus/cpp_weekly/issues JASON'S BOOKS ► C++23 Best Practices Amazon Paperback: amzn.to/47MEAhj Leanpub Ebook: leanpub.com/cpp23_best_practices/ ► C++ Best Practices Amazon Paperback: amzn.to/3wpAU3Z Leanpub Ebook: leanpub.com/cppbestpractices JASON'S PUZZLE BOOKS ► Programming Puzzles Big Book Amazon Paperback: amzn.to/4plj0cb Leanpub Ebook: leanpub.com/programming_puzzles_for_everyone ► Object Lifetime Puzzlers Book 1 Amazon Paperback: amzn.to/3g6Ervj Leanpub Ebook: leanpub.com/objectlifetimepuzzlers_book1 ► Object Lifetime Puzzlers Book 2 Amazon Paperback: amzn.to/3whdUDU Leanpub Ebook: leanpub.com/objectlifetimepuzzlers_book2 ► Object Lifetime Puzzlers Book 3 Leanpub Ebook: leanpub.com/objectlifetimepuzzlers_book3 ► Copy and Reference Puzzlers Book 1 Amazon Paperback: amzn.to/3g7ZVb9 Leanpub Ebook: leanpub.com/copyandreferencepuzzlers_book1 ► Copy and Reference Puzzlers Book 2 Amazon Paperback: amzn.to/3X1LOIx Leanpub Ebook: leanpub.com/copyandreferencepuzzlers_book2 ► Copy and Reference Puzzlers Book 3 Leanpub Ebook: leanpub.com/copyandreferencepuzzlers_book3 ► 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/cpp_starter_project ► C++ Best Practices Forkable Coding Standards - github.com/cpp-best-practices/cppbestpractices O'Reilly VIDEOS ► Inheritance and Polymorphism in C++ - oreilly.com/library/view/inheritance-and-polymorphism/978149… ► Learning C++ Best Practices - oreilly.com/library/view/learning-c-best/9781491954898/

Why it's here

1 person recommends this

What people say. Recommended as a resource explaining C++20 changes that enable constexpr std::vector.

Moments people linked to

user643011on Stack Overflow • Recommends

On “Cannot create constexpr std::vector”

There is a proposal to make std::vector constexpr : https://github.com/ldionne/wg21/blob/master/generated/p1004r1.pdf There is a whole talk about the upcoming C++20/23 changes: link to this video So check again with C++20 ! edit: constexpr std::vector has been approved for C++20 ! https://www.reddit.com/r/cpp/comments/au0c4x/201902_kona_iso_c_committee_trip_report_c20/ edit 2019-10: gcc trunk (with --std=c++2a flag) has started to implement constexpr new (a prerequisite for constexpr vector ). See: link to this video edit 2021-11: both constexpr std::vector and constexpr std::basic_string are now implemented in gcc 12 ( https://en.cppreference.com/w/cpp/compiler_support )
93View the answer