Skip to content

Latest commit

 

History

History
511 lines (306 loc) · 22.9 KB

File metadata and controls

511 lines (306 loc) · 22.9 KB

Core language

Table of contents


Introduction and overview

🔗

main()

🎥


ABI

🔗

🎥

Itanium C++ ABI

The Itanium C++ ABI is an ABI for C++. As an ABI, it gives precise rules for implementing the language, ensuring that separately-compiled parts of a program can successfully interoperate. It is not platform-specific and can be layered portably on top of an arbitrary C ABI. It is used as the standard C++ ABI for many major operating systems on all major architectures, and is implemented in many major C++ compilers, including GCC and Clang.

🔗


Attributes

🎥

[[nodiscard]]

This attribute encourages the compiler to issue a warning if the return value is discarded.

📝

  • Conservative approach suggested by N.Josuttis:
    • Should be added:
      • existing APIs: not using the return value always is a “huge mistake”; not using the return value is a source of trouble and easily can happen;
      • new APIs: not using the return value is usually an error.
    • Should not be added:
      • existing APIs: not using the return value is a possible/common way of programming at least for some input; not using the return value makes no sense but doesn’t hurt.

🔗

[[trivially_relocatable]]

This attribute specifies that the relocation operation for an object is trivial: moving the object and then immediately destroying the original is equivalent to memcpy. This attribute is not yet in the standard.

See Relocation – Memory – Optimization and hardware.


Declarations

const and mutable

📝

  • In C++98: const means “logically const”, in C++11 const means “thread safe” (bitwise const or internally synchronized).
  • In C++98: mutable means “not observably non-const”, in C++11 mutable means “thread safe” (bitwise const or internally synchronized).

🔗

🎥

constexpr

🔗

🎥

friend

Friend function templates

See Friend function templates – Function templates – Templates.

Hidden friends

🔗

inline

🔗

Storage class specifiers

🔗


Exceptions

🔗


Expressions

Operators

🔗

Order of evaluation

🔗

Type conversions

dynamic_cast

🎥

Type punning

📝

🔗

🎥


Functions

Argument-dependent lookup

🔗

:movie:

Function wrappers

std::function

🔗

Lambda expressions

🔗

🎥


Standards

C++17

🎥

  • A.Meredith. C++17 in breadth (not depth). Part I, Part II – CppCon (2016)

C++2a

🎥


Structured bindings

🔗


Tricks and subtleties

🔗

🎥

Accessing private and protected members

🔗

Embedding binary data

🔗


Types

Aggregate, trivial and POD types

🔗

Floating-point types

See also Floating-point arithmetic – Numeric data structures and algorithms.

🔗

__float128

🔗

Function types

Integral types

🔗

🎥

Opaque typedefs

An opaque type is a new type that is distinct from and distinguishable from its underlying type, yet retaining layout compatibility with its underlying type. The intent is to allow programmer control (1) over substitutability between an opaque alias and its underlying type, and (2) over overloading based on any parameter whose type is or involves an opaque alias.

📝

  • Nobody seemed to know, so I wrote a mail to the author, Walter E. Brown, and asked him. He told me that Bjarne doesn’t like that feature (anymore), so it is very unlikely that it will come anytime soon. Apparently C++ won’t get strong typedefs as core language feature. [J.Müller]

  • See Opaque typedefs – Patterns and idioms for implementations at the library level.

References

🔗

Lifetime of a temporary

🔗

Rvalue references and move semantics

🔗

🎥