From Jason Turner

[diff.cpp14]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpzmv6o54t/{from.md → to.md} +129 -127
tmp/tmpzmv6o54t/{from.md → to.md} RENAMED
@@ -1,117 +1,114 @@
1
  ## C++ and ISO C++14 <a id="diff.cpp14">[[diff.cpp14]]</a>
2
 
3
  This subclause lists the differences between C++ and ISO C++14 (ISO/IEC
4
- 14882:2014, *Programming Languages — C++*), by the chapters of this
5
- document.
6
 
7
- ### Clause [[lex]]: lexical conventions <a id="diff.cpp14.lex">[[diff.cpp14.lex]]</a>
8
 
9
- [[lex.phases]] **Change:** Removal of trigraph support as a required
10
- feature. **Rationale:** Prevents accidental uses of trigraphs in non-raw
11
- string literals and comments. **Effect on original feature:** Valid
12
- C++14code that uses trigraphs may not be valid or may have different
13
- semantics in this International Standard. Implementations may choose to
14
- translate trigraphs as specified in C++14if they appear outside of a raw
15
- string literal, as part of the *implementation-defined* mapping from
16
- physical source file characters to the basic source character set.
17
 
18
- [[lex.ppnumber]] **Change:** *pp-number* can contain `p` *sign* and `P`
19
- *sign*. **Rationale:** Necessary to enable hexadecimal floating
20
- literals. **Effect on original feature:** Valid C++14code may fail to
21
- compile or produce different results in this International Standard.
22
- Specifically, character sequences like `0p+0` and `0e1_p+0` are three
23
- separate tokens each in C++14, but one single token in this
24
- International Standard.
25
 
26
  ``` cpp
27
  #define F(a) b ## a
28
- int b0p = F(0p+0); // ill-formed; equivalent to ``int b0p = b0p + 0;'' in C++14
29
  ```
30
 
31
- ### Clause [[expr]]: expressions <a id="diff.cpp14.expr">[[diff.cpp14.expr]]</a>
32
 
33
- [[expr.post.incr]], [[expr.pre.incr]] **Change:** Remove increment
34
- operator with `bool` operand. **Rationale:** Obsolete feature with
35
- occasionally surprising semantics. **Effect on original feature:** A
36
- valid C++14expression utilizing the increment operator on a `bool`
37
- lvalue is ill-formed in this International Standard. Note that this
38
- might occur when the lvalue has a type given by a template parameter.
39
 
40
- [[expr.new]], [[expr.delete]] **Change:** Dynamic allocation mechanism
41
- for over-aligned types. **Rationale:** Simplify use of over-aligned
42
- types. **Effect on original feature:** In C++14code that uses a
43
- *new-expression* to allocate an object with an over-aligned class type,
44
- where that class has no allocation functions of its own,
45
- `::operator new(std::size_t)` is used to allocate the memory. In this
46
- International Standard, `::operator new(std::size_t, std::align_val_t)`
47
- is used instead.
48
 
49
- ### Clause [[dcl.dcl]]: declarations <a id="diff.cpp14.dcl.dcl">[[diff.cpp14.dcl.dcl]]</a>
50
 
51
- [[dcl.stc]] **Change:** Removal of `register` *storage-class-specifier*.
52
  **Rationale:** Enable repurposing of deprecated keyword in future
53
  revisions of this International Standard. **Effect on original
54
  feature:** A valid C++14 declaration utilizing the `register`
55
  *storage-class-specifier* is ill-formed in this International Standard.
56
  The specifier can simply be removed to retain the original meaning.
57
 
58
- [[dcl.spec.auto]] **Change:** `auto` deduction from *braced-init-list*.
59
- **Rationale:** More intuitive deduction behavior. **Effect on original
60
- feature:** Valid C++14code may fail to compile or may change meaning in
61
- this International Standard. For example:
62
 
63
  ``` cpp
64
  auto x1{1}; // was std::initializer_list<int>, now int
65
  auto x2{1, 2}; // was std::initializer_list<int>, now ill-formed
66
  ```
67
 
68
- ### Clause [[dcl.decl]]: declarators <a id="diff.cpp14.decl">[[diff.cpp14.decl]]</a>
69
-
70
- [[dcl.fct]] **Change:** Make exception specifications be part of the
71
- type system. **Rationale:** Improve type-safety. **Effect on original
72
- feature:** Valid C++14code may fail to compile or change meaning in this
73
- International Standard:
74
 
75
  ``` cpp
76
  void g1() noexcept;
77
  void g2();
78
  template<class T> int f(T *, T *);
79
  int x = f(g1, g2); // ill-formed; previously well-formed
80
  ```
81
 
82
- [[dcl.init.aggr]] **Change:** Definition of an aggregate is extended to
83
- apply to user-defined types with base classes. **Rationale:** To
84
- increase convenience of aggregate initialization. **Effect on original
85
- feature:** Valid C++14code may fail to compile or produce different
86
- results in this International Standard; initialization from an empty
87
- initializer list will perform aggregate initialization instead of
88
- invoking a default constructor for the affected types:
89
 
90
  ``` cpp
91
  struct derived;
92
  struct base {
93
  friend struct derived;
94
  private:
95
  base();
96
  };
97
  struct derived : base {};
98
 
99
- derived d1{}; // Error. The code was well-formed before.
100
  derived d2; // still OK
101
  ```
102
 
103
- ### Clause [[special]]: special member functions <a id="diff.cpp14.special">[[diff.cpp14.special]]</a>
104
 
105
- [[class.inhctor.init]] **Change:** Inheriting a constructor no longer
106
- injects a constructor into the derived class. **Rationale:** Better
107
- interaction with other language features. **Effect on original
108
- feature:** Valid C++14code that uses inheriting constructors may not be
109
- valid or may have different semantics. A *using-declaration* that names
110
- a constructor now makes the corresponding base class constructors
111
- visible to initializations of the derived class rather than declaring
112
- additional derived class constructors.
113
 
114
  ``` cpp
115
  struct A {
116
  template<typename T> A(T, typename T::type = 0);
117
  A(int);
@@ -123,101 +120,106 @@ struct B : A {
123
  B b(42L); // now calls B(int), used to call B<long>(long),
124
  // which called A(int) due to substitution failure
125
  // in A<long>(long).
126
  ```
127
 
128
- ### Clause [[temp]]: templates <a id="diff.cpp14.temp">[[diff.cpp14.temp]]</a>
129
 
130
- [[temp.deduct.type]] **Change:** Allowance to deduce from the type of a
131
- non-type template argument. **Rationale:** In combination with the
132
- ability to declare non-type template arguments with placeholder types,
133
- allows partial specializations to decompose from the type deduced for
134
- the non-type template argument. **Effect on original feature:** Valid
135
- C++14code may fail to compile or produce different results in this
136
- International Standard:
137
 
138
  ``` cpp
139
  template <int N> struct A;
140
  template <typename T, T N> int foo(A<N> *) = delete;
141
  void foo(void *);
142
  void bar(A<0> *p) {
143
  foo(p); // ill-formed; previously well-formed
144
  }
145
  ```
146
 
147
- ### Clause [[except]]: exception handling <a id="diff.cpp14.except">[[diff.cpp14.except]]</a>
148
 
149
- [[except.spec]] **Change:** Remove dynamic exception specifications.
150
- **Rationale:** Dynamic exception specifications were a deprecated
151
- feature that was complex and brittle in use. They interacted badly with
152
- the type system, which became a more significant issue in this
153
- International Standard where (non-dynamic) exception specifications are
154
- part of the function type. **Effect on original feature:** A valid
155
- C++14function declaration, member function declaration, function pointer
156
- declaration, or function reference declaration, if it has a potentially
157
- throwing dynamic exception specification, will be rejected as ill-formed
158
- in this International Standard. Violating a non-throwing dynamic
159
- exception specification will call `terminate` rather than `unexpected`
160
- and might not perform stack unwinding prior to such a call.
161
 
162
- ### Clause [[library]]: library introduction <a id="diff.cpp14.library">[[diff.cpp14.library]]</a>
163
 
164
- [[namespace.future]] **Change:** New reserved namespaces. **Rationale:**
165
- Reserve namespaces for future revisions of the standard library that
166
- might otherwise be incompatible with existing programs. **Effect on
167
- original feature:** The global namespaces `std` followed by an arbitrary
168
- sequence of digits is reserved for future standardization. Valid
169
- C++14code that uses such a top-level namespace, e.g., `std2`, may be
170
- invalid in this International Standard.
171
 
172
- ### Clause [[utilities]]: general utilities library <a id="diff.cpp14.utilities">[[diff.cpp14.utilities]]</a>
 
 
 
 
 
 
173
 
174
- [[func.wrap]] **Change:** Constructors taking allocators removed.
175
- **Rationale:** No implementation consensus. **Effect on original
 
 
 
 
 
 
 
 
 
 
176
  feature:** Valid C++14 code may fail to compile or may change meaning in
177
- this International Standard. Specifically, constructing a
178
- `std::function` with an allocator is ill-formed and uses-allocator
179
- construction will not pass an allocator to `std::function` constructors
180
- in this International Standard.
181
-
182
- [[util.smartptr.shared]] **Change:** Different constraint on conversions
183
- from `unique_ptr`. **Rationale:** Adding array support to `shared_ptr`,
184
- via the syntax `shared_ptr<T[]>` and `shared_ptr<T[N]>`. **Effect on
185
- original feature:** Valid C++14code may fail to compile or may change
186
- meaning in this International Standard. For example:
187
 
188
  ``` cpp
189
  #include <memory>
190
  std::unique_ptr<int[]> arr(new int[1]);
191
  std::shared_ptr<int> ptr(std::move(arr)); // error: int(*)[] is not compatible with int*
192
  ```
193
 
194
- ### Clause [[strings]]: strings library <a id="diff.cpp14.string">[[diff.cpp14.string]]</a>
195
 
196
- [[basic.string]] **Change:** Non-const `.data()` member added.
197
- **Rationale:** The lack of a non-const `.data()` differed from the
198
- similar member of `std::vector`. This change regularizes behavior for
199
- this International Standard. **Effect on original feature:** Overloaded
200
- functions which have differing code paths for `char*` and `const char*`
201
- arguments will execute differently when called with a non-const string’s
202
- `.data()` member in this International Standard.
203
 
204
  ``` cpp
205
  int f(char *) = delete;
206
  int f(const char *);
207
  string s;
208
  int x = f(s.data()); // ill-formed; previously well-formed
209
  ```
210
 
211
- ### Clause [[containers]]: containers library <a id="diff.cpp14.containers">[[diff.cpp14.containers]]</a>
212
 
213
- [[associative.reqmts]] **Change:** Requirements change: **Rationale:**
214
- Increase portability, clarification of associative container
215
- requirements. **Effect on original feature:** Valid C++14code that
216
- attempts to use associative containers having a comparison object with
217
- non-const function call operator may fail to compile in this
218
- International Standard:
219
 
220
  ``` cpp
221
  #include <set>
222
 
223
  struct compare
@@ -232,21 +234,21 @@ int main() {
232
  const std::set<int, compare> s;
233
  s.find(0);
234
  }
235
  ```
236
 
237
- ### Annex  [[depr]]: compatibility features <a id="diff.cpp14.depr">[[diff.cpp14.depr]]</a>
238
 
239
  **Change:** The class templates `auto_ptr`, `unary_function`, and
240
  `binary_function`, the function templates `random_shuffle`, and the
241
  function templates (and their return types) `ptr_fun`, `mem_fun`,
242
  `mem_fun_ref`, `bind1st`, and `bind2nd` are not defined. **Rationale:**
243
- Superseded by new features. **Effect on original feature:** Valid
244
- C++14code that uses these class templates and function templates may
245
- fail to compile in this International Standard.
246
 
247
  **Change:** Remove old iostreams members \[depr.ios.members\].
248
  **Rationale:** Redundant feature for compatibility with pre-standard
249
- code has served its time. **Effect on original feature:** A valid
250
- C++14program using these identifiers may be ill-formed in this
251
- International Standard.
252
 
 
1
  ## C++ and ISO C++14 <a id="diff.cpp14">[[diff.cpp14]]</a>
2
 
3
  This subclause lists the differences between C++ and ISO C++14 (ISO/IEC
4
+ 14882:2014, *Programming Languages — C++*), in addition to those listed
5
+ above, by the chapters of this document.
6
 
7
+ ### [[lex]]: lexical conventions <a id="diff.cpp14.lex">[[diff.cpp14.lex]]</a>
8
 
9
+ **Change:** Removal of trigraph support as a required feature.
10
+ **Rationale:** Prevents accidental uses of trigraphs in non-raw string
11
+ literals and comments. **Effect on original feature:** Valid C++14 code
12
+ that uses trigraphs may not be valid or may have different semantics in
13
+ this International Standard. Implementations may choose to translate
14
+ trigraphs as specified in C++14 if they appear outside of a raw string
15
+ literal, as part of the *implementation-defined* mapping from physical
16
+ source file characters to the basic source character set.
17
 
18
+ **Change:** *pp-number* can contain `p` *sign* and `P` *sign*.
19
+ **Rationale:** Necessary to enable
20
+ *hexadecimal-floating-point-literal*s. **Effect on original feature:**
21
+ Valid C++14 code may fail to compile or produce different results in
22
+ this International Standard. Specifically, character sequences like
23
+ `0p+0` and `0e1_p+0` are three separate tokens each in C++14, but one
24
+ single token in this International Standard. For example:
25
 
26
  ``` cpp
27
  #define F(a) b ## a
28
+ int b0p = F(0p+0); // ill-formed; equivalent to ``int b0p = b0p + 0;'' in C++14{}
29
  ```
30
 
31
+ ### [[expr]]: expressions <a id="diff.cpp14.expr">[[diff.cpp14.expr]]</a>
32
 
33
+ **Change:** Remove increment operator with `bool` operand.
34
+ **Rationale:** Obsolete feature with occasionally surprising semantics.
35
+ **Effect on original feature:** A valid C++14 expression utilizing the
36
+ increment operator on a `bool` lvalue is ill-formed in this
37
+ International Standard. Note that this might occur when the lvalue has a
38
+ type given by a template parameter.
39
 
40
+ **Change:** Dynamic allocation mechanism for over-aligned types.
41
+ **Rationale:** Simplify use of over-aligned types. **Effect on original
42
+ feature:** In C++14 code that uses a *new-expression* to allocate an
43
+ object with an over-aligned class type, where that class has no
44
+ allocation functions of its own, `::operator new(std::size_t)` is used
45
+ to allocate the memory. In this International Standard,
46
+ `::operator new(std::size_t, std::align_val_t)` is used instead.
 
47
 
48
+ ### [[dcl.dcl]]: declarations <a id="diff.cpp14.dcl.dcl">[[diff.cpp14.dcl.dcl]]</a>
49
 
50
+ **Change:** Removal of `register` *storage-class-specifier*.
51
  **Rationale:** Enable repurposing of deprecated keyword in future
52
  revisions of this International Standard. **Effect on original
53
  feature:** A valid C++14 declaration utilizing the `register`
54
  *storage-class-specifier* is ill-formed in this International Standard.
55
  The specifier can simply be removed to retain the original meaning.
56
 
57
+ **Change:** `auto` deduction from *braced-init-list*. **Rationale:**
58
+ More intuitive deduction behavior. **Effect on original feature:** Valid
59
+ C++14 code may fail to compile or may change meaning in this
60
+ International Standard. For example:
61
 
62
  ``` cpp
63
  auto x1{1}; // was std::initializer_list<int>, now int
64
  auto x2{1, 2}; // was std::initializer_list<int>, now ill-formed
65
  ```
66
 
67
+ **Change:** Make exception specifications be part of the type system.
68
+ **Rationale:** Improve type-safety. **Effect on original feature:**
69
+ Valid C++14 code may fail to compile or change meaning in this
70
+ International Standard. For example:
 
 
71
 
72
  ``` cpp
73
  void g1() noexcept;
74
  void g2();
75
  template<class T> int f(T *, T *);
76
  int x = f(g1, g2); // ill-formed; previously well-formed
77
  ```
78
 
79
+ **Change:** Definition of an aggregate is extended to apply to
80
+ user-defined types with base classes. **Rationale:** To increase
81
+ convenience of aggregate initialization. **Effect on original feature:**
82
+ Valid C++14 code may fail to compile or produce different results in
83
+ this International Standard; initialization from an empty initializer
84
+ list will perform aggregate initialization instead of invoking a default
85
+ constructor for the affected types. For example:
86
 
87
  ``` cpp
88
  struct derived;
89
  struct base {
90
  friend struct derived;
91
  private:
92
  base();
93
  };
94
  struct derived : base {};
95
 
96
+ derived d1{}; // error; the code was well-formed in C++14{}
97
  derived d2; // still OK
98
  ```
99
 
100
+ ### [[class]]: classes <a id="diff.cpp14.class">[[diff.cpp14.class]]</a>
101
 
102
+ **Change:** Inheriting a constructor no longer injects a constructor
103
+ into the derived class. **Rationale:** Better interaction with other
104
+ language features. **Effect on original feature:** Valid C++14 code that
105
+ uses inheriting constructors may not be valid or may have different
106
+ semantics. A *using-declaration* that names a constructor now makes the
107
+ corresponding base class constructors visible to initializations of the
108
+ derived class rather than declaring additional derived class
109
+ constructors.
110
 
111
  ``` cpp
112
  struct A {
113
  template<typename T> A(T, typename T::type = 0);
114
  A(int);
 
120
  B b(42L); // now calls B(int), used to call B<long>(long),
121
  // which called A(int) due to substitution failure
122
  // in A<long>(long).
123
  ```
124
 
125
+ ### [[temp]]: templates <a id="diff.cpp14.temp">[[diff.cpp14.temp]]</a>
126
 
127
+ **Change:** Allowance to deduce from the type of a non-type template
128
+ argument. **Rationale:** In combination with the ability to declare
129
+ non-type template arguments with placeholder types, allows partial
130
+ specializations to decompose from the type deduced for the non-type
131
+ template argument. **Effect on original feature:** Valid C++14 code may
132
+ fail to compile or produce different results in this International
133
+ Standard. For example:
134
 
135
  ``` cpp
136
  template <int N> struct A;
137
  template <typename T, T N> int foo(A<N> *) = delete;
138
  void foo(void *);
139
  void bar(A<0> *p) {
140
  foo(p); // ill-formed; previously well-formed
141
  }
142
  ```
143
 
144
+ ### [[except]]: exception handling <a id="diff.cpp14.except">[[diff.cpp14.except]]</a>
145
 
146
+ **Change:** Remove dynamic exception specifications. **Rationale:**
147
+ Dynamic exception specifications were a deprecated feature that was
148
+ complex and brittle in use. They interacted badly with the type system,
149
+ which became a more significant issue in this International Standard
150
+ where (non-dynamic) exception specifications are part of the function
151
+ type. **Effect on original feature:** A valid C++14 function
152
+ declaration, member function declaration, function pointer declaration,
153
+ or function reference declaration, if it has a potentially throwing
154
+ dynamic exception specification, will be rejected as ill-formed in this
155
+ International Standard. Violating a non-throwing dynamic exception
156
+ specification will call `terminate` rather than `unexpected` and might
157
+ not perform stack unwinding prior to such a call.
158
 
159
+ ### [[library]]: library introduction <a id="diff.cpp14.library">[[diff.cpp14.library]]</a>
160
 
161
+ **Change:** New headers. **Rationale:** New functionality. **Effect on
162
+ original feature:** The following C++ headers are new: `<any>`,
163
+ `<charconv>`, `<execution>`, `<filesystem>`, `<memory_resource>`,
164
+ `<optional>`,
165
+ `<string_view>`, and `<variant>`. Valid C++14 code that `#include`s
166
+ headers with these names may be invalid in this International Standard.
 
167
 
168
+ **Change:** New reserved namespaces. **Rationale:** Reserve namespaces
169
+ for future revisions of the standard library that might otherwise be
170
+ incompatible with existing programs. **Effect on original feature:** The
171
+ global namespaces `std` followed by an arbitrary sequence of *digit*s
172
+ [[lex.name]] are reserved for future standardization. Valid C++14 code
173
+ that uses such a top-level namespace, e.g., `std2`, may be invalid in
174
+ this International Standard.
175
 
176
+ ### [[utilities]]: general utilities library <a id="diff.cpp14.utilities">[[diff.cpp14.utilities]]</a>
177
+
178
+ **Change:** Constructors taking allocators removed. **Rationale:** No
179
+ implementation consensus. **Effect on original feature:** Valid C++14
180
+ code may fail to compile or may change meaning in this International
181
+ Standard. Specifically, constructing a `std::function` with an allocator
182
+ is ill-formed and uses-allocator construction will not pass an allocator
183
+ to `std::function` constructors in this International Standard.
184
+
185
+ **Change:** Different constraint on conversions from `unique_ptr`.
186
+ **Rationale:** Adding array support to `shared_ptr`, via the syntax
187
+ `shared_ptr<T[]>` and `shared_ptr<T[N]>`. **Effect on original
188
  feature:** Valid C++14 code may fail to compile or may change meaning in
189
+ this International Standard. For example:
 
 
 
 
 
 
 
 
 
190
 
191
  ``` cpp
192
  #include <memory>
193
  std::unique_ptr<int[]> arr(new int[1]);
194
  std::shared_ptr<int> ptr(std::move(arr)); // error: int(*)[] is not compatible with int*
195
  ```
196
 
197
+ ### [[strings]]: strings library <a id="diff.cpp14.string">[[diff.cpp14.string]]</a>
198
 
199
+ **Change:** Non-const `.data()` member added. **Rationale:** The lack of
200
+ a non-const `.data()` differed from the similar member of `std::vector`.
201
+ This change regularizes behavior for this International Standard.
202
+ **Effect on original feature:** Overloaded functions which have
203
+ differing code paths for `char*` and `const char*` arguments will
204
+ execute differently when called with a non-const string’s `.data()`
205
+ member in this International Standard.
206
 
207
  ``` cpp
208
  int f(char *) = delete;
209
  int f(const char *);
210
  string s;
211
  int x = f(s.data()); // ill-formed; previously well-formed
212
  ```
213
 
214
+ ### [[containers]]: containers library <a id="diff.cpp14.containers">[[diff.cpp14.containers]]</a>
215
 
216
+ **Change:** Requirements change: **Rationale:** Increase portability,
217
+ clarification of associative container requirements. **Effect on
218
+ original feature:** Valid C++14 code that attempts to use associative
219
+ containers having a comparison object with non-const function call
220
+ operator may fail to compile in this International Standard:
 
221
 
222
  ``` cpp
223
  #include <set>
224
 
225
  struct compare
 
234
  const std::set<int, compare> s;
235
  s.find(0);
236
  }
237
  ```
238
 
239
+ ### [[depr]]: compatibility features <a id="diff.cpp14.depr">[[diff.cpp14.depr]]</a>
240
 
241
  **Change:** The class templates `auto_ptr`, `unary_function`, and
242
  `binary_function`, the function templates `random_shuffle`, and the
243
  function templates (and their return types) `ptr_fun`, `mem_fun`,
244
  `mem_fun_ref`, `bind1st`, and `bind2nd` are not defined. **Rationale:**
245
+ Superseded by new features. **Effect on original feature:** Valid C++14
246
+ code that uses these class templates and function templates may fail to
247
+ compile in this International Standard.
248
 
249
  **Change:** Remove old iostreams members \[depr.ios.members\].
250
  **Rationale:** Redundant feature for compatibility with pre-standard
251
+ code has served its time. **Effect on original feature:** A valid C++14
252
+ program using these identifiers may be ill-formed in this International
253
+ Standard.
254