Versions of C++ and the major differences
Modern C++11
- Smartpointers RAII (Resource Acquisition Is Initialization), data / scope driven auto malloc/free
- Unique: Can't be copied, single object reference, best when possible
- shared: tracks copies, free when last user out of scope or reset
- weak: observe, check before ref (may be dangling). use to monitor / avoid circular dependencies.
- std::move to quick copy complex objects to a new owner without actually duplicating the data.
- && rvalue references. Allows hand off of ownership. e.g. from class constructor to main program variable.
- Lambdas e.g. [=i, &str](int tab) { ... } -> String
- "capture lists" filter the method of reference to non-static scope variables.
- [], no access to local variables. Everything is in the param list or block
- [&], reference most commonly used if a variable needs to be modified
- [=], make a value copy of all local variables used in the lambda
- etc. combine the above and mention specific variables
- param ()
- block {}
- return type -> trailing, only needed if it can't be inferred.
- auto type is inferred from initializer. No need to re specify component types from a complex type, handy in templates, verifies init and can't cast.
- for (int num : numbers) where numbers is a vector of ints
- constexpr and compile time eval (??)
- more data types in the std library. e.g. array, unordered_map and _set
- thread, mutex, future, atomic (????)
C++17
- destructuring. auto[id, name] = item; //item = {1, "apple"}
- std::optional type (parameter may not be specified)
- std::variant type (may be one of several types)
- std::string_view (??)
C++20
- Concepts to constrain templates (??_)
- Co routines
- Modules
- <=>
file: /Techref/language/ccpp/cpp_versions.htm,
2KB, , updated: 2025年6月22日 17:50, local time: 2025年9月6日 18:21,
owner:
JMN-EFP-786,
©2025 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Questions?<A HREF="http://massmind.org/Techref/language/ccpp/cpp_versions.htm"> Versions of C++ and the major differences</A>
Did you find what you needed?
Welcome to massmind.org!
Welcome to massmind.org!
.