Modern CPP 11-20 Sum
Modern CPP 11-20 Sum
--------------------------------------------------------------------------
Which are the new features in the C++ 11 standard?
Range-Based for Loops: The range-based for loop simplifies iterating over
sequences, containers, and arrays by automatically managing loop variables and
eliminating the need for manual index manipulation.
Type Inference (auto and decltype): The 'auto' keyword enables type inference,
allowing the compiler to deduce the variable's type from its initializer.
'decltype' lets you determine the type of an expression at compile time.
Concurrency and Multithreading Support: C++11 introduced the <thread> header for
multi-threading support, including std::thread, std::mutex,
std::condition_variable, and other synchronization primitives. The 'std::thread'
class was introduced to support concurrent programming. Additionally, the
standard library provides facilities for creating threads, synchronizing
operations, and handling tasks concurrently.
nullptr: C++11 introduced the 'nullptr' keyword, which is a safer and more
expressive alternative to the traditional use of 'NULL' or '0' for representing
null pointers.
Explicitly Deleted and Defaulted Functions: With C++11, you can explicitly
define functions to be deleted or defaulted, improving code clarity and
preventing unintended behavior.
Override and Final Keywords: Introduced final and override keywords to provide
better control over inheritance and virtual functions. The 'override' keyword
lets you explicitly indicate that a member function is intended to override a
virtual function from a base class. The 'final' keyword prevents further
derivation or overriding.
Auto Type Deduction: C++11 introduced the auto keyword, allowing you to declare
variables with their type automatically deduced from their initializer. This
simplifies code and promotes type safety.
Auto Type Inference: The auto keyword allows the compiler to automatically infer
the data type of a variable based on its initializer.
Type Traits and static_assert: Introduced type traits, which allow compile-time
introspection of types, and the static_assert keyword for compile-time
assertions. The <type_traits> header introduced a set of type traits that enable
compile-time introspection of types, allowing for more generic and flexible
code.
Atomic Operations: The <atomic> header introduced atomic types and operations
for safe and efficient manipulation of shared variables in a multithreaded
environment.
--------------------------------------------------------------------------------
--------
Which are the new features in the C++ 14 standard?
Generic Lambdas: C++14 introduced the ability to use lambdas in a more flexible
manner by allowing lambda functions to deduce their parameter types using the
auto keyword. This facilitates the creation of more generic and reusable lambda
functions. C++14 extended lambda functions to support auto-typed parameters in
lambda expressions, making it easier to write generic code.
Return Type Deduction: C++14 introduced the ability to deduce the return type of
a function based on its return statements, using the auto keyword. Functions in
C++14 are allowed to deduce their return types using the auto keyword, enabling
cleaner and more concise code without sacrificing type safety.
Binary Literals and Digit Separators: C++14 introduced the ability to represent
binary literals (e.g., 0b110101) using the 0b or 0B prefix, making it easier to
work with binary values. Additionally, digit separators (single quotes e.g.,
1'000'000) can now be used within numeric literals to enhance readability.
Extended sizeof Expressions: The sizeof operator in C++14 can now be used with
expressions that have no side effects, offering more flexibility and consistency
in its usage.
New Standard Library Features: C++14 introduced several new features to the
standard library, including additions to the <tuple> and <utility> headers,
which enhance the functionality and usability of these library components.
Unicode Character Literals: C++14 enhanced the support for Unicode character
literals, enabling more accurate representation and manipulation of Unicode
characters in the source code.
decltype(auto): This feature lets you deduce the type of a variable using
decltype, similar to how auto is used for type deduction.
Heterogeneous Lookup for Containers: The C++14 standard extended the container
classes (such as std::unordered_map and std::unordered_set) to support
heterogeneous lookups using types different from the key type.
--------------------------------------------------------------------------------
--------
Which are the new features in the C++ 17 ("C++17 ISO/IEC 14882:2017") standard?
if and switch with Initialization: C++17 extended the if and switch statements
to support variable initialization within the statement itself, enhancing code
conciseness and reducing redundancy.
Fold Expressions: Fold expressions provide a compact and expressive way to apply
binary operations over a parameter pack, simplifying code that operates on
variadic template parameters.
constexpr if: C++17 introduced the constexpr if statement, which allows you to
conditionally compile parts of a function template based on compile-time
conditions, improving template specialization.
New Standard Library Features: C++17 introduced several new features in the
standard library, including new algorithms, support for filesystem operations
(<filesystem>), and enhanced support for string handling and manipulation.
New Attributes: C++17 added new attributes, such as [[fallthrough]] for switch
statements and [[nodiscard]] for indicating that a return value should not be
ignored.
--------------------------------------------------------------------------------
--------
Which are the new features in the C++ 20 standard?
Ranges: The Ranges library simplifies and enhances the manipulation of sequences
of values, making it easier to work with collections of data.
Modules: The Modules feature aims to improve the organization of code and reduce
compile times by allowing you to define interface units separately from
implementation units.
Improved Support for Lambdas: C++20 enhances lambdas by allowing them to appear
in unevaluated contexts and enabling parameter lists to include template and
requires clauses.
Calendar and Time Zone Library: C++20 introduces the <chrono> library with
additional support for working with dates, times, and time zones.
--------------------------------------------------------------------------------
--------