Changes

Jump to: navigation, search

Programming Stream C11 C++11

157 bytes added, 10:26, 3 May 2012
no edit summary
 
Agreed Detail Changes to OOP344/BTP300
OOP344/BTP300 – == C++ Part==
* new - add to align with C++11
** types - specification and qualification
::: trivial - redefinition of char modified to be the size necessary to store 8-bit coding of UTF-8 and basic execution character set
wchar_t, char16_t, char32_t – Unicode support for UTF-16 and UTF-32
::: trivial - constexpr – function or object constructor is a compile-time constant – qualifier on types other than int enum
::: trivial - decltype() deduces the type of the expression at compile time
::: trivial - enum forward declarations admissible as long as the size is specified
::: using syntax alternative for typedef – using OtherType = ... ;
::: trivial - thread_local storage duration – variable unique to the thread
** expressions
::: trivial - sizeof() works on members of uninstantiated classes
::: trivial - L' ' and L” “ - prefix for wide character
::: trivial - codepoint constants defined using \u \U
::: string literals defined using prefixes u8” ” u” ” and U” ”
::: trivial - R” “ raw string literal avoids escaping strings manually cf. XML files, scripts, regex
::: trivial - R can be combined with wide-character literal or Unicode prefixes
** functions
::: anonymous (lambda) functions [](int x){ return x + 2; } - return type is implicit as long as all expressions return the same type
::: alternate trailing-return-type function syntax auto foo(int a, int b) -> decltype(a + b) { return a + b; }
** encapsulation
::: constexpr ctor – contains only constant expression
::: rvalues – modifiable temporaries – T&& – to avoid deep copies on pass/return by value - move constructor T::T(T&&) copies pointer out of rvalue into new temp and sets rvalue pointer to nullptr – move assignment operator T& T::operator=(T&&)
::: trivial - delegated construction allows default value to be changed without recompilation of application code (e.g. SomeType() : SomeType(42))
::: trivial - SomeType() = default explicit default
::: trivial - explicit conversion operators – keyword can be applied here also
::: trivial - less restrictions on members of a union
** inheritance
::: trivial - inherited constructors – using BaseClass::BaseClass
::: trivial - override identifier of base class virtual function
::: trivial - final identifier – prevent further overrides
** polymorphism - fuller generic programming support - templates
::: trivial - extern template – do not instantiate template in this translation unit
::: trivial - right angle bracket closes the template where it is reasonable
::: using syntax for typedef – cf. Template aliases
::: trivial - variadic templates just extends variadic syntax to templates
::: trailing return type function syntax auto foo(const T& a, const T& b) -> decltype(a + b) { return a + b; } - return type is unknown for template type T
::: trivial - static_assert(,) for templates
** library
::: initializer lists – extends from POD cases to all classes including std containers - initialization-list constructor – T::T(std::initializer_list<type> list) – initializer list is constant and the data in its members cannot be changed
::: multi-threading support
** other features
::: uniform initialization – uses initializer-list syntax – aggregate initialization, constructor, return list without explicit type
::: trivial - static_assert(,) – tests assertion at compile-time
OOP344/BTP300 – * C Part
:: extend existing pre-defined macros to align with C11
:: pre-defined macros to identify installed features __STDC_*__
:: trivial - currently covered in C++ part - add to align with C99
:: inline functions
:: anonymous structures and unions
** new - add to align with C99 and C++11
::: bool macro, _Bool data type (C99)
::: variadic macros
::: Unicode support – same as C++
::: static assertions – evaluated later than #if and #error
::: bounds-checking – list of safe alternative library functions for robust programming
::: multi-threading support

Navigation menu