From Jason Turner

[diff.cpp11]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpwe0oowo1/{from.md → to.md} +55 -57
tmp/tmpwe0oowo1/{from.md → to.md} RENAMED
@@ -1,58 +1,58 @@
1
  ## C++ and ISO C++11 <a id="diff.cpp11">[[diff.cpp11]]</a>
2
 
3
  This subclause lists the differences between C++ and ISO C++11 (ISO/IEC
4
- 14882:2011, *Programming Languages — C++*), by the chapters of this
5
- document.
6
 
7
- ### Clause [[lex]]: lexical conventions <a id="diff.cpp11.lex">[[diff.cpp11.lex]]</a>
8
 
9
- [[lex.ppnumber]] **Change:** *pp-number* can contain one or more single
10
- quotes. **Rationale:** Necessary to enable single quotes as digit
11
- separators. **Effect on original feature:** Valid C++11code may fail to
12
- compile or may change meaning in this International Standard. For
13
- example, the following code is valid both in C++11and in this
14
- International Standard, but the macro invocation produces different
15
- outcomes because the single quotes delimit a character literal in C++11,
16
- whereas they are digit separators in this International Standard:
17
 
18
  ``` cpp
19
  #define M(x, ...) __VA_ARGS__
20
  int x[2] = { M(1'2,3'4, 5) };
21
- // int x[2] = { 5 \ \ \ \ \ } --- C++11
22
  // int x[2] = { 3'4, 5 } --- this International Standard
23
  ```
24
 
25
- ### Clause [[basic]]: basic concepts <a id="diff.cpp11.basic">[[diff.cpp11.basic]]</a>
26
 
27
- [[basic.stc.dynamic.deallocation]] **Change:** New usual (non-placement)
28
- deallocator. **Rationale:** Required for sized deallocation. **Effect on
29
- original feature:** Valid C++11code could declare a global placement
30
- allocation function and deallocation function as follows:
31
 
32
  ``` cpp
33
  void* operator new(std::size_t, std::size_t);
34
  void operator delete(void*, std::size_t) noexcept;
35
  ```
36
 
37
  In this International Standard, however, the declaration of
38
  `operator delete` might match a predefined usual (non-placement)
39
- `operator delete` ([[basic.stc.dynamic]]). If so, the program is
40
  ill-formed, as it was for class member allocation functions and
41
- deallocation functions ([[expr.new]]).
42
 
43
- ### Clause [[expr]]: expressions <a id="diff.cpp11.expr">[[diff.cpp11.expr]]</a>
44
 
45
- [[expr.cond]] **Change:** A conditional expression with a throw
46
- expression as its second or third operand keeps the type and value
47
- category of the other operand. **Rationale:** Formerly mandated
48
- conversions (lvalue-to-rvalue ([[conv.lval]]), array-to-pointer (
49
- [[conv.array]]), and function-to-pointer ([[conv.func]]) standard
50
- conversions), especially the creation of the temporary due to
51
- lvalue-to-rvalue conversion, were considered gratuitous and surprising.
52
- **Effect on original feature:** Valid C++11code that relies on the
53
- conversions may behave differently in this International Standard:
54
 
55
  ``` cpp
56
  struct S {
57
  int x = 1;
58
  void mf() { x = 2; }
@@ -72,57 +72,55 @@ sizeof(true ? "" : throw 0)
72
  ```
73
 
74
  In C++11, the expression yields `sizeof(const char*)`. In this
75
  International Standard, it yields `sizeof(const char[1])`.
76
 
77
- ### Clause [[dcl.dcl]]: declarations <a id="diff.cpp11.dcl.dcl">[[diff.cpp11.dcl.dcl]]</a>
78
 
79
- [[dcl.constexpr]] **Change:** `constexpr` non-static member functions
80
- are not implicitly `const` member functions. **Rationale:** Necessary to
81
- allow `constexpr` member functions to mutate the object. **Effect on
82
- original feature:** Valid C++11code may fail to compile in this
83
- International Standard. For example, the following code is valid in
84
- C++11 but invalid in this International Standard because it declares the
85
- same member function twice with different return types:
86
 
87
  ``` cpp
88
  struct S {
89
  constexpr const int &f();
90
  int &f();
91
  };
92
  ```
93
 
94
- ### Clause [[dcl.decl]]: declarators <a id="diff.cpp11.dcl.decl">[[diff.cpp11.dcl.decl]]</a>
95
-
96
- [[dcl.init.aggr]] **Change:** Classes with default member initializers
97
- can be aggregates. **Rationale:** Necessary to allow default member
98
- initializers to be used by aggregate initialization. **Effect on
99
- original feature:** Valid C++11code may fail to compile or may change
100
- meaning in this International Standard.
101
 
102
  ``` cpp
103
- struct S { // Aggregate in C++14onwards.
104
  int m = 1;
105
  };
106
  struct X {
107
  operator int();
108
  operator S();
109
  };
110
  X a{};
111
- S b{a}; // uses copy constructor in C++11,
112
  // performs aggregate initialization in this International Standard
113
  ```
114
 
115
- ### Clause [[library]]: library introduction <a id="diff.cpp11.library">[[diff.cpp11.library]]</a>
116
 
117
- [[headers]] **Change:** New header. **Rationale:** New functionality.
118
- **Effect on original feature:** The C++header `<shared_mutex>` is new.
119
- Valid C++11code that `#include`s a header with that name may be invalid
120
- in this International Standard.
121
-
122
- ### Clause [[input.output]]: input/output library <a id="diff.cpp11.input.output">[[diff.cpp11.input.output]]</a>
123
-
124
- [[c.files]] **Change:** `gets` is not defined. **Rationale:** Use of
125
- `gets` is considered dangerous. **Effect on original feature:** Valid
126
- C++11code that uses the `gets` function may fail to compile in this
127
  International Standard.
128
 
 
 
 
 
 
 
 
 
1
  ## C++ and ISO C++11 <a id="diff.cpp11">[[diff.cpp11]]</a>
2
 
3
  This subclause lists the differences between C++ and ISO C++11 (ISO/IEC
4
+ 14882:2011, *Programming Languages — C++*), in addition to those listed
5
+ above, by the chapters of this document.
6
 
7
+ ### [[lex]]: lexical conventions <a id="diff.cpp11.lex">[[diff.cpp11.lex]]</a>
8
 
9
+ **Change:** *pp-number* can contain one or more single quotes.
10
+ **Rationale:** Necessary to enable single quotes as digit separators.
11
+ **Effect on original feature:** Valid C++11 code may fail to compile or
12
+ may change meaning in this International Standard. For example, the
13
+ following code is valid both in C++11 and in this International
14
+ Standard, but the macro invocation produces different outcomes because
15
+ the single quotes delimit a *character-literal* in C++11, whereas they
16
+ are digit separators in this International Standard:
17
 
18
  ``` cpp
19
  #define M(x, ...) __VA_ARGS__
20
  int x[2] = { M(1'2,3'4, 5) };
21
+ // int x[2] = { 5 \ \ \ \ \ } --- C++11{}
22
  // int x[2] = { 3'4, 5 } --- this International Standard
23
  ```
24
 
25
+ ### [[basic]]: basics <a id="diff.cpp11.basic">[[diff.cpp11.basic]]</a>
26
 
27
+ **Change:** New usual (non-placement) deallocator. **Rationale:**
28
+ Required for sized deallocation. **Effect on original feature:** Valid
29
+ C++11 code could declare a global placement allocation function and
30
+ deallocation function as follows:
31
 
32
  ``` cpp
33
  void* operator new(std::size_t, std::size_t);
34
  void operator delete(void*, std::size_t) noexcept;
35
  ```
36
 
37
  In this International Standard, however, the declaration of
38
  `operator delete` might match a predefined usual (non-placement)
39
+ `operator delete` [[basic.stc.dynamic]]. If so, the program is
40
  ill-formed, as it was for class member allocation functions and
41
+ deallocation functions [[expr.new]].
42
 
43
+ ### [[expr]]: expressions <a id="diff.cpp11.expr">[[diff.cpp11.expr]]</a>
44
 
45
+ **Change:** A conditional expression with a throw expression as its
46
+ second or third operand keeps the type and value category of the other
47
+ operand. **Rationale:** Formerly mandated conversions (lvalue-to-rvalue
48
+ [[conv.lval]], array-to-pointer [[conv.array]], and function-to-pointer
49
+ [[conv.func]] standard conversions), especially the creation of the
50
+ temporary due to lvalue-to-rvalue conversion, were considered gratuitous
51
+ and surprising. **Effect on original feature:** Valid C++11 code that
52
+ relies on the conversions may behave differently in this International
53
+ Standard:
54
 
55
  ``` cpp
56
  struct S {
57
  int x = 1;
58
  void mf() { x = 2; }
 
72
  ```
73
 
74
  In C++11, the expression yields `sizeof(const char*)`. In this
75
  International Standard, it yields `sizeof(const char[1])`.
76
 
77
+ ### [[dcl.dcl]]: declarations <a id="diff.cpp11.dcl.dcl">[[diff.cpp11.dcl.dcl]]</a>
78
 
79
+ **Change:** `constexpr` non-static member functions are not implicitly
80
+ `const` member functions. **Rationale:** Necessary to allow `constexpr`
81
+ member functions to mutate the object. **Effect on original feature:**
82
+ Valid C++11 code may fail to compile in this International Standard. For
83
+ example, the following code is valid in C++11 but invalid in this
84
+ International Standard because it declares the same member function
85
+ twice with different return types:
86
 
87
  ``` cpp
88
  struct S {
89
  constexpr const int &f();
90
  int &f();
91
  };
92
  ```
93
 
94
+ **Change:** Classes with default member initializers can be aggregates.
95
+ **Rationale:** Necessary to allow default member initializers to be used
96
+ by aggregate initialization. **Effect on original feature:** Valid C++11
97
+ code may fail to compile or may change meaning in this International
98
+ Standard. For example:
 
 
99
 
100
  ``` cpp
101
+ struct S { // Aggregate in C++14{} onwards.
102
  int m = 1;
103
  };
104
  struct X {
105
  operator int();
106
  operator S();
107
  };
108
  X a{};
109
+ S b{a}; // uses copy constructor in C++11{},
110
  // performs aggregate initialization in this International Standard
111
  ```
112
 
113
+ ### [[library]]: library introduction <a id="diff.cpp11.library">[[diff.cpp11.library]]</a>
114
 
115
+ **Change:** New header. **Rationale:** New functionality. **Effect on
116
+ original feature:** The C++ header `<shared_mutex>` is new. Valid C++11
117
+ code that `#include`s a header with that name may be invalid in this
 
 
 
 
 
 
 
118
  International Standard.
119
 
120
+ ### [[input.output]]: input/output library <a id="diff.cpp11.input.output">[[diff.cpp11.input.output]]</a>
121
+
122
+ **Change:** `gets` is not defined. **Rationale:** Use of `gets` is
123
+ considered dangerous. **Effect on original feature:** Valid C++11 code
124
+ that uses the `gets` function may fail to compile in this International
125
+ Standard.
126
+