You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/overview/2017/cpp-conformance-improvements-2017.md
+39Lines changed: 39 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -330,6 +330,45 @@ void bar(A<0> *p)
330
330
331
331
[P0426R1](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0426r1.html) Changes to `std::traits_type` member functions `length`, `compare`, and `find` in order to make `std::string_view` usable in constant expressions. (In Visual Studio 2017 version 15.6, supported for Clang/LLVM only. In version 15.7 Preview 2, support is nearly complete for ClXX as well.)
332
332
333
+
## <aname="improvements_159"></a> Improvements in Visual Studio 2017 version 15.9
334
+
335
+
### Left-to-right evaluation order for operators ->*, [], >>, and <<
336
+
337
+
Starting in C++17, the operands of the operators ->*, [], >>, and \<\< must be evaluated in left-to-right order. There are two cases in which the compiler is unable to guarantee this order:
338
+
- when one of the operand expressions is an object passed by value or contains an object passed by value, or
339
+
- when compiled by using **/clr**, and one of the operands is a field of an object or an array element.
340
+
341
+
The compiler emits warning [C4866](https://docs.microsoft.com/cpp/error-messages/compiler-warnings/c4866?view=vs-2017) when it can't guarantee left-to-right evaluation. This warning is only generated if **/std:c++17** or later is specified, as the left-to-right order requirement of these operators was introduced in C++17.
342
+
343
+
To resolve this warning, first consider whether left-to-right evaluation of the operands is necessary, such as when evaluation of the operands might produce order-dependent side-effects. In many cases, the order in which operands are evaluated does not have an observable effect. If the order of evaluation must be left-to-right, consider whether you can pass the operands by const reference instead. This change eliminates the warning in the following code sample.
int operator>>(HasCopyConstructor a, HasCopyConstructor b) { return a.x >> b.x; }
359
+
360
+
// This version of operator>> does not trigger the warning:
361
+
// int operator>>(const HasCopyConstructor& a, const HasCopyConstructor& b) { return a.x >> b.x; }
362
+
363
+
int main()
364
+
{
365
+
HasCopyConstructor a{ 1 };
366
+
HasCopyConstructor b{ 2 };
367
+
368
+
a>>b; // C4866 for call to operator>>
369
+
};
370
+
```
371
+
333
372
## Bug fixes in Visual Studio versions 15.0, [15.3](#update_153), [15.5](#update_155), [15.7](#update_157), [15.8](#update_158), and [15.9](#update_159)
0 commit comments