Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does C1x inherit from C++?

Tags:

c++

c

c11

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++?

like image 788
Johannes Schaub - litb Avatar asked Dec 06 '11 08:12

Johannes Schaub - litb


2 Answers

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++.

like image 161
justin Avatar answered Sep 27 '22 23:09

justin


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).

like image 23
MSalters Avatar answered Sep 27 '22 22:09

MSalters