From Jason Turner

[diff.cpp14]

Diff to HTML by rtfpessoa

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