Skip to content

Commit b0f36bf

Browse files
author
mikeblome
committed
fixed merge conflicts
2 parents c0f314a + e4a44aa commit b0f36bf

23 files changed

+1197
-307
lines changed

docs/TOC.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# [Visual C++ in Visual Studio 2017 RC](visual-cpp-in-visual-studio.md)
2-
# [What's New for Visual C++ in Visual Studio 2017 RC](what-s-new-for-visual-cpp-in-visual-studio.md)
1+
# [Visual C++ in Visual Studio 2017](visual-cpp-in-visual-studio.md)
2+
# [What's New for Visual C++ in Visual Studio 2017](what-s-new-for-visual-cpp-in-visual-studio.md)
33
# [C++ conformance improvements in Visual Studio 2017](cpp-conformance-improvements-2017.md)
44
## [Visual C++ Language Conformance](visual-cpp-language-conformance.md)
55
# [Supported Platforms (Visual C++)](supported-platforms-visual-cpp.md)

docs/cpp/constexpr-cpp.md

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ translation.priority.ht:
3434
- "zh-tw"
3535
---
3636
# constexpr (C++)
37-
The keyword `constexpr` was introduced in C++11 and improved in C++14. It means *constant expression*. Like `const`, it can be applied to variables so that a compiler error will be raised if any code attempts to modify the value. Unlike `const`, `constexpr` can also be applied to functions and class constructors. `constexpr` indicates that the value, or return value, is constant and, if possible, will be computed at compile time. A `constexpr` integral value can be used wherever a const integer is required, such as in template arguments and array declarations. And when a value can be computed at compile time instead of run time, it can help your program can run faster and use less memory.
37+
The keyword `constexpr` was introduced in C++11 and improved in C++14. It means *constant expression*. Like `const`, it can be applied to variables so that a compiler error will be raised if any code attempts to modify the value. Unlike `const`, `constexpr` can also be applied to functions and class constructors. `constexpr` indicates that the value, or return value, is constant and, if possible, will be computed at compile time. A `constexpr` integral value can be used wherever a const integer is required, such as in template arguments and array declarations. And when a value can be computed at compile time instead of run time, it can help your program run faster and use less memory.
3838

3939
## Syntax
4040

4141
```cpp
42-
constexpr literal-type identifier = constant-expression;constexpr literal-type identifier { constant-expression };constexpr literal-type identifier(params );constexpr ctor (params);
42+
constexpr literal-type identifier = constant-expression;
43+
constexpr literal-type identifier { constant-expression };
44+
constexpr literal-type identifier(params );
45+
constexpr ctor (params);
4346
```
4447
4548
#### Parameters
@@ -64,8 +67,18 @@ constexpr literal-type identifier = constant-expression;constexpr literal-typ
6467
6568
## constexpr variables
6669
The primary difference between const and constexpr variables is that the initialization of a const variable can be deferred until run time whereas a constexpr variable must be initialized at compile time. All constexpr variables are const.
70+
71+
- A variable can be declared with `constexpr`, if it has a literal type and is initialized. If the initialization is performed by a constructor, the constructor must be declared as `constexpr`.
6772
68-
```
73+
- A reference may be declared as constexpr if the object that it references has been initialized by a constant expression and any implicit conversions that are invoked during initialization are also constant expressions.
74+
75+
- All declarations of a `constexpr` variable or function must have the `constexpr` specifier.
76+
77+
78+
79+
80+
81+
```cpp
6982
constexpr float x = 42.0;
7083
constexpr float y{108};
7184
constexpr float z = exp(5, 3);
@@ -75,9 +88,38 @@ constexpr int k = j + 1; //Error! j not a constant expression
7588
```
7689

7790
## constexpr functions
78-
A `constexpr` function is one whose return value can be computed at compile when consuming code requires it. A `constexpr` function must accept and return only literal types. When its arguments are `constexpr` values, and consuming code requires the return value at compile time, for example to initialize a `constexpr` variable or provide a non-type template argument, it produces a compile-time constant. When called with non-`constexpr` arguments, or when its value is not required at compile-time, it produces a value at run time like a regular function. (This dual behavior saves you from having to write `constexpr` and non-`constexpr` versions of the same function.)
91+
A `constexpr` function is one whose return value can be computed at compile when consuming code requires it. When its arguments are `constexpr` values, and consuming code requires the return value at compile time, for example to initialize a `constexpr` variable or provide a non-type template argument, it produces a compile-time constant. When called with non-`constexpr` arguments, or when its value is not required at compile-time, it produces a value at run time like a regular function. (This dual behavior saves you from having to write `constexpr` and non-`constexpr` versions of the same function.)
92+
93+
A `constexpr` function or constructor is implicitly `inline`.
94+
95+
The following rules apply to constexpr functions:
96+
97+
- A `constexpr` function must accept and return only literal types.
98+
99+
- A `constexpr` function can be recursive.
100+
101+
- It cannot be [virtual](../cpp/virtual-cpp.md). A a constructor cannot be defined as constexpr if the enclosing class has any virtual base classes.
102+
103+
- The body can be defined as `= default` or `= delete`.
104+
105+
- The body can contain no `goto` statements or try blocks.
106+
107+
- An explicit specialization of a non-constexpr template can be declared as `constexpr`:
108+
109+
- An explicit specialization of a `constexpr` template does not have to also be `constexpr`:
110+
111+
112+
<!--conformance note-->
113+
The following rules apply to constexpr functions in Visual Studio 2017 and later:
114+
115+
- It may contain if and switch statements, and all looping statements including for, range-based for, while, and do-while
116+
117+
- It may contain local variable declarations, but the variable must be initialized, must be a literal type, and cannot be static or thread-local. The locally-declared variable is not required to be const and may mutate.
118+
119+
- A constexpr non-static member function is not required to be implicitly const.
120+
79121

80-
```
122+
```cpp
81123
constexpr float exp(float x, int n)
82124
{
83125
return n == 0 ? 1 :
@@ -89,23 +131,7 @@ constexpr float exp(float x, int n)
89131
> [!TIP]
90132
> Note: In the Visual Studio debugger, you can tell whether a `constexpr` function is being evaluated at compile time by putting a breakpoint inside it. If the breakpoint is hit, the function was called at run-time. If not, then the function was called at compile time.
91133
92-
## General constexpr rules
93-
For a function, variable, constructor or static data member to be defined as `constexpr`, it must meet certain requirements:
94-
95-
- A `constexpr` function can be recursive. It cannot be [virtual](../cpp/virtual-cpp.md), and its return type and parameter types must all be literal types. The body can be defined as `= default` or `= delete`. Otherwise it must follow these rules: it contains no `goto` statements, try blocks, unitialized variables, or variable definitions that are not literal types, or that are static or thread-local. Additionally, a constructor cannot be defined as constexpr if the enclosing class has any virtual base classes.
96-
97-
- A variable can be declared with `constexpr`, if it has a literal type and is initialized. If the initialization is performed by a constructor, the constructor must be declared as `constexpr`.
98-
99-
- A reference may be declared as constexpr if the object that it references has been initialized by a constant expression and any implicit conversions that are invoked during initialization are also constant expressions.
100-
101-
- All declarations of a `constexpr` variable or function must have the `constexpr` specifier.
102-
103-
- An explicit specialization of a non-constexpr template can be declared as `constexpr`:
104-
105-
- An explicit specialization of a `constexpr` template does not have to also be `constexpr`:
106-
107-
- A `constexpr` function or constructor is implicitly `inline`.
108-
134+
109135
## Example
110136
The following example shows `constexpr` variables, functions and a user-defined type. Note that in the last statement in main(), the `constexpr` member function GetValue() is a run-time call because the value is not required to be known at compile time.
111137
@@ -182,4 +208,4 @@ int main()
182208
183209
## See Also
184210
[Declarations and Definitions](../cpp/declarations-and-definitions-cpp.md)
185-
[const](../cpp/constexpr-cpp.md)
211+
[const](../cpp/const-cpp.md)

docs/cpp/initializers.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ int main() {
388388
389389
- no virtual member functions
390390
391-
- no brace-or-equal initializers for non-static members
391+
> [!NOTE]
392+
> <!--conformance note-->In Visual Studio 2015 and earlier, an aggregate is not allowed to have brace-or-equal initializers for non-static members. This restriction was removed in the C++14 standard and implemented in Visual Studio 2017.
392393
393394
Aggregate initializers consist of a braced initialization list, with or without an equals sign, as in the following example:
394395
@@ -435,7 +436,7 @@ myArr3: 8 9 10 0 0
435436
```
436437

437438
> [!IMPORTANT]
438-
> Array members that declared but not explicitly initialized during aggregate initialization are zero-initialized, as in `myArr3` above.
439+
> Array members that are declared but not explicitly initialized during aggregate initialization are zero-initialized, as in `myArr3` above.
439440

440441
#### Initializing unions and structs
441442
If a union does not have a constructor, you can initialize it with a single value (or with another instance of a union). The value is used to initialize the first non-static field. This is different from struct initialization, in which the first value in the initializer is used to initialize the first field, the second to initialize the second field, and so on. Compare the initialization of unions and structs in the following example:

docs/cppcx/compiler-and-linker-options-c-cx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ An environment variable, C++/CX compiler options, and linker options support the
2424

2525
|Option|Description|
2626
|------------|-----------------|
27-
|[/ZW](../build/reference/zw-windows-runtime-compilation.md)<br /><br /> /ZW:nostdlib|Enables [!INCLUDE[wrt](../cppcx/includes/wrt-md.md)] language extensions.<br /><br /> The `nostdlib` parameter prevents the compiler from using the standard, predefined search path to find assembly and .winmd files.<br /><br /> The **/ZW** compiler option implicitly specifies the following compiler options:<br /><br /> - [/FI](../build/reference/fi-name-atlde.md) vccorlib.h, which forces inclusion of the vccorlib.h header file that defines many types that are required by the compiler.<br />- [/FU](../build/reference/fu-name-forced-hash-using-file.md) Windows.winmd, which forces inclusion of the Windows.winmd metadata file that's provided by the operating system and defines many types in the [!INCLUDE[wrt](../cppcx/includes/wrt-md.md)].<br />- **/FU** Platform.winmd, which forces inclusion of the Platform.winmd metadata file that's provided by the compiler and defines most types in the Platform family of namespaces.|
27+
|[/ZW](../build/reference/zw-windows-runtime-compilation.md)<br /><br /> /ZW:nostdlib|Enables [!INCLUDE[wrt](../cppcx/includes/wrt-md.md)] language extensions.<br /><br /> The `nostdlib` parameter prevents the compiler from using the standard, predefined search path to find assembly and .winmd files.<br /><br /> The **/ZW** compiler option implicitly specifies the following compiler options:<br /><br /> - **/FI** vccorlib.h, which forces inclusion of the vccorlib.h header file that defines many types that are required by the compiler.<br />- [/FU](../build/reference/fu-name-forced-hash-using-file.md) Windows.winmd, which forces inclusion of the Windows.winmd metadata file that's provided by the operating system and defines many types in the [!INCLUDE[wrt](../cppcx/includes/wrt-md.md)].<br />- **/FU** Platform.winmd, which forces inclusion of the Platform.winmd metadata file that's provided by the compiler and defines most types in the Platform family of namespaces.|
2828
|[/AI](../build/reference/ai-specify-metadata-directories.md) *dir*|Adds a directory, which is specified by the *dir* parameter, to the search path that the compiler uses to find assembly and .winmd files.|
2929
|**/FU** *file*|Forces the inclusion of the specified module, or .winmd file. That is, you don't have to specify `#using`*file* in your source code. The compiler automatically forces the inclusion of its own Windows metadata file, Platform.winmd.|
3030
|/D "WINAPI_FAMILY=2"|Creates a definition that enables the use of a subset of the Win32 SDK that's compatible with the [!INCLUDE[wrt](../cppcx/includes/wrt-md.md)].|
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: "default::(type_name)::Equals Method | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "12/30/2016"
5+
ms.prod: "windows-client-threshold"
6+
ms.technology: ""
7+
ms.reviewer: ""
8+
ms.suite: ""
9+
ms.tgt_pltfrm: ""
10+
ms.topic: "language-reference"
11+
f1_keywords:
12+
- "Platform/Platform::Object::Equals"
13+
dev_langs:
14+
- "C++"
15+
ms.assetid: 4450f835-06fc-4758-8d0a-72cf00007873
16+
caps.latest.revision: 4
17+
author: "ghogen"
18+
ms.author: "ghogen"
19+
manager: "ghogen"
20+
---
21+
# default::(type_name)::Equals Method
22+
Determines whether the specified object is equal to the current object.
23+
24+
## Syntax
25+
26+
```cpp
27+
28+
bool Equals(
29+
Object^ obj
30+
)
31+
```
32+
33+
## Parameters
34+
obj
35+
The object to compare.
36+
37+
## Return Value
38+
`true` if the objects are equal, otherwise `false`.
39+
40+
## Requirements
41+
**Minimum supported client:** [!INCLUDE[win8](../cppcx/includes/win8-md.md)]
42+
43+
**Minimum supported server:** [!INCLUDE[winserver8](../cppcx/includes/winserver8-md.md)]
44+
45+
**Namespace:** default
46+
47+
**Header:** vccorlib.h
48+
49+
## See Also
50+
[default namespace](../cppcx/default-namespace.md)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: "default::(type_name)::GetHashCode Method | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "12/30/2016"
5+
ms.prod: "windows-client-threshold"
6+
ms.technology: ""
7+
ms.reviewer: ""
8+
ms.suite: ""
9+
ms.tgt_pltfrm: ""
10+
ms.topic: "language-reference"
11+
f1_keywords:
12+
- "Platform/Platform::Object::GetHashCode"
13+
dev_langs:
14+
- "C++"
15+
ms.assetid: 58ea60f8-f820-4103-9b9b-b6635ada3fa5
16+
caps.latest.revision: 4
17+
author: "ghogen"
18+
ms.author: "ghogen"
19+
manager: "ghogen"
20+
---
21+
# default::(type_name)::GetHashCode Method
22+
Returns the hash code for this instance.
23+
24+
## Syntax
25+
26+
```cpp
27+
public:int GetHashCode()
28+
```
29+
30+
## Return Value
31+
The hash code for this instance.
32+
33+
## Requirements
34+
**Minimum supported client:** [!INCLUDE[win8](../cppcx/includes/win8-md.md)]
35+
36+
**Minimum supported server:** [!INCLUDE[winserver8](../cppcx/includes/winserver8-md.md)]
37+
38+
**Namespace:** default
39+
40+
**Header:** vccorlib.h
41+
42+
## See Also
43+
[default namespace](../cppcx/default-namespace.md)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: "default::(type_name)::GetType Method | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "12/30/2016"
5+
ms.prod: "windows-client-threshold"
6+
ms.technology: ""
7+
ms.reviewer: ""
8+
ms.suite: ""
9+
ms.tgt_pltfrm: ""
10+
ms.topic: "language-reference"
11+
f1_keywords:
12+
- "Platform/Platform::Object::GetType"
13+
dev_langs:
14+
- "C++"
15+
ms.assetid: 21d0bf92-fac4-48cd-9108-c6f57ba1196a
16+
caps.latest.revision: 5
17+
author: "ghogen"
18+
ms.author: "ghogen"
19+
manager: "ghogen"
20+
---
21+
# default::(type_name)::GetType Method
22+
Returns a Platform::Type^ that represents the current type.
23+
24+
## Syntax
25+
26+
```cpp
27+
28+
Platform::Type^ GetType()
29+
```
30+
31+
## Return Value
32+
A [Platform::Type](../cppcx/platform-type-class.md)^ object that represents the current object.
33+
34+
## Requirements
35+
**Minimum supported client:** [!INCLUDE[win8](../cppcx/includes/win8-md.md)]
36+
37+
**Minimum supported server:** [!INCLUDE[winserver8](../cppcx/includes/winserver8-md.md)]
38+
39+
**Namespace:** default
40+
41+
**Header:** vccorlib.h
42+
43+
## See Also
44+
[default namespace](../cppcx/default-namespace.md)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: "default::(type_name)::ToString Method | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "12/30/2016"
5+
ms.prod: "windows-client-threshold"
6+
ms.technology: ""
7+
ms.reviewer: ""
8+
ms.suite: ""
9+
ms.tgt_pltfrm: ""
10+
ms.topic: "language-reference"
11+
f1_keywords:
12+
- "Platform/Platform::Object::ToString"
13+
dev_langs:
14+
- "C++"
15+
ms.assetid: 2541955f-d844-4bd8-944d-185198c86579
16+
caps.latest.revision: 4
17+
author: "ghogen"
18+
ms.author: "ghogen"
19+
manager: "ghogen"
20+
---
21+
# default::(type_name)::ToString Method
22+
Returns a string that represents the current type.
23+
24+
## Syntax
25+
26+
```cpp
27+
28+
String^ ToString()
29+
```
30+
31+
## Return Value
32+
A string that represents the current object.
33+
34+
## Requirements
35+
**Minimum supported client:** [!INCLUDE[win8](../cppcx/includes/win8-md.md)]
36+
37+
**Minimum supported server:** [!INCLUDE[winserver8](../cppcx/includes/winserver8-md.md)]
38+
39+
**Namespace:** default
40+
41+
**Header:** vccorlib.h
42+
43+
## See Also
44+
[default namespace](../cppcx/default-namespace.md)

docs/cppcx/enums-c-cx.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ manager: "ghogen"
1818
C++/CX supports the `public enum class` keyword, which is analagous to a standard C++ `scoped enum`. When you use an enumerator that's declared by using the `public enum class` keyword, you must use the enumeration identifier to scope each enumerator value.
1919

2020
## Remarks
21-
A `public enum class` that doesn't have an access specifier, such as `public`, is treated as a standard C++ [scoped enum](../cpp/enumerations.md).
21+
A `public enum class` that doesn't have an access specifier, such as `public`, is treated as a standard C++ [scoped enum](../cpp/enumerations-cpp.md).
2222

23-
A `public enum class` or `public enum struct` declaration can have an underlying type of any integral type although the [!INCLUDE[wrt](../cppcx/includes/wrt-md.md)] itself requires that the type be int32, or uint32 for a flags enum. The following syntax describes the parts of an `public enum class` or `public enum struct`. For more information, see [enum class](../Topic/enum%20class%20%20\(C++%20Component%20Extensions\).md).
23+
A `public enum class` or `public enum struct` declaration can have an underlying type of any integral type although the [!INCLUDE[wrt](../cppcx/includes/wrt-md.md)] itself requires that the type be int32, or uint32 for a flags enum. The following syntax describes the parts of an `public enum class` or `public enum struct`.
2424

2525
This example shows how to define a public enum class:
2626

0 commit comments

Comments
 (0)