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/build/reference/zc-twophase.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ The **/Zc:twoPhase-** option, under **/permissive-**, tells the compiler to use
17
17
18
18
Visual Studio 2017 version 15.3 and later: Under [/permissive-](permissive-standards-conformance.md), the compiler uses two-phase name lookup for template name resolution. If you also specify **/Zc:twoPhase-**, the compiler reverts to its previous non-conforming class template and function template name resolution and substitution behavior. When **/permissive-** isn't specified, the non-conforming behavior is the default.
19
19
20
-
The Windows SDK header files in version 10.0.15063.0 (Creators Update or Redstone 2) and earlier versions don't work correctly in conformance mode. **/Zc:twoPhase-** is required to compile code for those SDK versions when you use **/permissive-** in Visual Studio 2017 version 15.3 and later versions. Versions of the Windows SDK starting with version 10.0.15254.0 (Redstone 3 or Fall Creators Update) work correctly in conformance mode and don't require the **/Zc:twoPhase-** option.
20
+
The Windows SDK header files in version 10.0.15063.0 (Creators Update or RS2) and earlier don't work in conformance mode. **/Zc:twoPhase-** is required to compile code for those SDK versions when you use **/permissive-**. Versions of the Windows SDK starting with version 10.0.15254.0 (Fall Creators Update or RS3) work correctly in conformance mode. They don't require the **/Zc:twoPhase-** option.
21
21
22
22
Use **/Zc:twoPhase-** if your code requires the old behavior to compile correctly. Strongly consider updating your code to conform to the standard.
23
23
@@ -37,7 +37,7 @@ By default, or in Visual Studio 2017 version 15.3 and later when you specify bot
37
37
38
38
As a result, if the template body has syntax errors, but the template never gets instantiated, the compiler doesn't diagnose the errors.
39
39
40
-
Another effect of this behavior is in overload resolution. Non-standard side-effects occur because of the way the token stream is expanded at the site of instantiation. Symbols that weren't visible at the template declaration may be visible at the point of instantiation, and participate in overload resolution. You may find templates change behavior based on code that wasn't visible at template definition, contrary to the standard.
40
+
Another effect of this behavior is in overload resolution. Non-standard behavior occurs because of the way the token stream is expanded at the site of instantiation. Symbols that weren't visible at the template declaration may be visible at the point of instantiation. That means they can participate in overload resolution. You may find templates change behavior based on code that wasn't visible at template definition, contrary to the standard.
41
41
42
42
For example, consider this code:
43
43
@@ -65,6 +65,8 @@ int main()
65
65
}
66
66
```
67
67
68
+
Here's the output when you use the default mode, conformance mode, and conformance mode with **/Zc:twoPhase-** compiler options:
When compiled in conformance mode under **/permissive-**, this program prints "`Standard two-phase`", because the second overload of `func` isn't visible when the compiler encounters the template. If you add **/Zc:twoPhase-**, the program prints "`Microsoft one-phase`". The output is the same as when you don't specify **/permissive-**.
83
-
84
-
*Dependent names* are names that depend on a template parameter. These names have lookup behavior that is also different under **/Zc:twoPhase-**.
84
+
When compiled in conformance mode under **/permissive-**, this program prints "`Standard two-phase`", because the second overload of `func` isn't visible when the compiler reaches the template. If you add **/Zc:twoPhase-**, the program prints "`Microsoft one-phase`". The output is the same as when you don't specify **/permissive-**.
85
85
86
-
In conformance mode, dependent names aren't bound at the point of the template's definition. Instead, the compiler looks them up when it instantiates the template. For function calls with a dependent function name, the name binds to functions visible at the call site in the template's definition. Additional overloads from argument-dependent lookup are added, both at the point of the template definition, and at the point of template instantiation.
86
+
*Dependent names* are names that depend on a template parameter. These names have lookup behavior that is also different under **/Zc:twoPhase-**. In conformance mode, dependent names aren't bound at the point of the template's definition. Instead, the compiler looks them up when it instantiates the template. For function calls with a dependent function name, the name gets bound to functions visible at the call site in the template definition. Additional overloads from argument-dependent lookup are added, both at the point of the template definition, and at the point of template instantiation.
87
87
88
-
Two-phase lookup consists of the lookup for non-dependent names during template definition, and the lookup for dependent names during template instantiation. Under **/Zc:twoPhase-**, the compiler doesn't do argument-dependent lookup separately from ordinary, unqualified lookup. That is, it doesn't do two-phase lookup, so the results of overload resolution may be different.
88
+
Two-phase lookup consists of two parts: The lookup for non-dependent names during template definition, and the lookup for dependent names during template instantiation. Under **/Zc:twoPhase-**, the compiler doesn't do argument-dependent lookup separately from unqualified lookup. That is, it doesn't do two-phase lookup, so the results of overload resolution may be different.
0 commit comments