Frage

It is well known that both C++ takes features from C but that C also standardizes C++ features. C1x has gained full expression temporaries (previously it only had sequence point temporaries). C1x also took from the C++11 threading effort.

I wonder what other features C1x took from C++?

War es hilfreich?

Lösung

The threading part of C1x (5.1.2.4) is taken almost literally from C++11. Terms like "conflict" and "atomic operations" have identical definitions, for all practical purposes.

Alignment is also inspired by C++11: the keyword is alignof, and the maximum aligned type is max_align_t (dropping the std:: namespace, of course).

Andere Tipps

Some similarities include:

  • static assertions: _Static_assert ( constant-expression , string-literal );
  • atomic support
  • unicode support - adds some typedefs (e.g. char16_t=uint_least16_t), literals, and utilities.
  • _Generic

_Generic is really more like overloading than what we have with the power of templates. The ubiquitous example of _Generic is:

#define cbrt(X) _Generic((X), long double: cbrtl, \
                              default: cbrt, \
                              float: cbrtf)(X) 

..but I'm not sure which were inherited expressly from C++.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top