Directory
1 constant-expression 3
2 NULL pointer 3
3 Type deduction 3
4 A range-based for Loop 3
5 Unlimited. Union 3
6 new String literal 4
7 Long Long int Category 4
8 Allow sizeof operator on a data member of type without explicit object 4
9 initializing a list of 5
Ten Unified Initialization 5
One modification of object construction and initialization of member variables 5
A displaying virtual function overloads 6
- Disallow default Constructors 6
- External Template 7
the Lambda function 7
- rvalue references and Move 7
- angle Brackets >> 8
- Multithreading Support 8
+ Multivariate Group Tuple 8
- Hash Table 8
1 constant-expression
Not currently supported by VS2013
constexpr int Test () { return 5; } int Main () { int buf[test () + 5]; return 0; } |
2 NULL pointer
int * pi = nullptr; int i = nullptr; int i = NULL; |
3 Type Deduction
Auto i = ' a '; Decltype (i) A; |
4 a range-based forLoops
int my_array[5] = { 1, 2, 3, 7, ten }; for (int &x:my_array) {} |
5 UnlimitedUnion
VS2013 currently does not support
class A { Public: A () {} A (int i) { this->i = i;} int i = ten; }; Union { int A1; double b; a ; }; |
6 New string Literals
c++11 will support three Unicode encoding methods: UTF-8,UTF-16, andUTF-32. In addition to the aboveChardefined changes, c++11 will add two new character categories: char16_tand thechar32_t. Each of them is designed to store UTF-16 and UTF-32 characters.
VS2013 currently does not support
Const char *s1 = U8"UTF-8 string."; Const char16_t *s2 = u"UTF-16 string."; Const char32_t *s3 = U"UTF-32 string."; |
7 Long Long intcategory
on a three-bit system, a long long int is an integer class that retains at least A valid bit of five. C99 introduced this category to standard C , and most of the C + + compilers currently support this category. c++11 will add this category to standard C + + .
8 Allowsizeofoperator on a data member of type without explicit object
VS2013 currently does not support
class A { Public: A () = Delete; // show notification compiler, do not generate default constructor A () = default; A (int i) { This->i = i; } int i; }; sizeof (A:: i) |
9 Initialization List
class A { Public: A (std::initializer_list<int> list) {} }; a = { 1, 4, 5, 6 }; |
10 Unified Initialization
class A { Public: string name; int ID; }; A a{ "Tom", 4 }; |
11 modification of object construction and initialization of member variables
class A { Public: A ():a(+) {} A (int i) { id = I; } int id = ten; }; |
12 Displaying virtual function overloads
class A { Public: Virtual void Test (int i) {} }; class B : public A { Virtual void Test (int i) override { } Virtual void test1 (float i) //override { } }; |
13 Disallow default constructors
class A { Public: A () = Delete; // show notification compiler, do not generate default constructor A () = default; A (int i) { This->i = i; } int i; }; |
14 External templates
Tells the compiler not to instantiate the template within the compilation unit.
extern Template class std::vector<int>; |
Lambda Functions
#include <algorithm> std::vector<int> A; A.push_back (1); A.push_back (2); A.push_back (3); int total = 0; Std::for_each (A.begin (), A.end (), [&total] (int x) {Total + = x;}); Std::cout << Total; |
15 Rvalue references andMove
Before c++03, the right value is on the right side of the operator and its value cannot be changed.
An lvalue is a persisted object that persists after the end of an expression, and the right value is a temporary object that does not exist after the end of an expression. The simplest way to determine an lvalue rvalue is to take an address to an expression.
class A {}; int Main () { int i = ten; int a = 4; int b = 3; i = a + b; a test = a(); return 0; } |
The function of move is to force an Lvalue value to be converted to an rvalue reference. If an object is explicitly referenced by another object and is no longer used, it can implement its copy constructor with a shallow copy, and the pointer member is NULL when the shallow copy is completed;
class A {}; int Main () { a ; a&& B = Move (a); } |
16 Corner Brackets >>
17 Multi-Threading support
18 Multi-tupletuple
#include <map> int i = ten; char c = ' a '; Const char *s = "Hello world"; typedef STD::tuple <int, char, const char *> mytuple ; Mytuple A (I, C, s); int i1 = std::get<0> (a); Const char *s1 = std::get<2> (a); |
19 Hash Table
Std::unordered_set
Std::unordered_multiset
Std::unordered_map
Std::unordered_multimap
#include <unordered_set> unordered_multiset<int> MySet; Myset.insert (ten); Myset.insert (a); unordered_multiset<int;::iterator it; for (it = Myset.begin (); It! = Myset.end (); ++it) { cout << *it << Endl; } |
Word Download Http://www.sundaboke.com/C++11.doc
C++11 new Features