Bartłomiej Filipek, 20th October 2022, cppstories.com
20 Smaller yet Handy
C++20Features
Part 2 - library
About Me
•Author of cppstories.com•~15y professional coding experience•4x Microsoft MVP, since 2018•C++ ISO Member•@Xara.com since 2014oMostly text related features for advanced document editors•Somehow addicted to C++
14. contains() member function of associative containers
8
for (auto& key: {"hello", "something"}) {if (strToInt.contains(key)) std::cout << key << ": Found\n";else std::cout << key << ": Not found\n";}
15. Consistent Container Erasure
9
In C++20, we get a bunch of free functions that have overloads for many containers and can remove elements:erase(container, value);erase_if(container, predicate);
Abbreviated Function Templates and Constrained Auto
Math constants
Template Syntax For Generic Lambdas
More constexpr in the Library
Constexpr Improvements
.starts_with() and .ends_with()
using enum
contains() member function of associative containers
Class-types in non-type template parameters
Consistent Container Erasure
New keyword constinit
Source Location
Designated Initializers
std::bind_front - for partial function application
Nodiscard Attribute Improvements
Heterogeneous lookup for unordered containers
Range-based for loop with Initializer
Smart pointer creation with default initialization
New keyword consteval - immediate functions
Safe integral comparisons
17
Bonus
•C++23 almost ready! - Feature freeze, sent for votingosome features:▪deducing this▪static operator()▪stacktrace▪more ranges, views and algorithms▪std::format improvements and std::print▪std::expected▪std::flat_map and std::flat_set▪module std▪std::generator▪...•Carbon, CppFront?