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/windows/comptrref-operator-void-star-star-operator.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ operator void**() const;
22
22
```
23
23
24
24
## Remarks
25
-
Deletes the current ComPtrRef object, casts the pointer to the interface that was represented by the ComPtrRef object as a pointer-to-pointer-to `void`, and then returns the cast pointer.
25
+
Deletes the current **ComPtrRef** object, casts the pointer to the interface that was represented by the **ComPtrRef** object as a pointer-to-pointer-to **void**, and then returns the cast pointer.
Copy file name to clipboardExpand all lines: docs/windows/constraints-on-generic-type-parameters-cpp-cli.md
+11-12Lines changed: 11 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,6 @@ In generic type or method declarations, you can qualify a type parameter with co
20
20
## Syntax
21
21
22
22
```
23
-
24
23
where type-parameter: constraint list
25
24
```
26
25
@@ -33,7 +32,7 @@ where type-parameter: constraint list
33
32
34
33
The list can also include a class. For the type argument to satisfy a base class constraint, it must be the same class as the constraint or derive from the constraint.
35
34
36
-
You can also specify `gcnew()` to indicate the type argument must have a public parameterless constructor; or `ref class` to indicate the type argument must be a reference type, including any class, interface, delegate, or array type; or `value class` to indicate the type argument must be a value type. Any value type except Nullable\<T> can be specified.
35
+
You can also specify `gcnew()` to indicate the type argument must have a public parameterless constructor; or **ref class** to indicate the type argument must be a reference type, including any class, interface, delegate, or array type; or **value class** to indicate the type argument must be a value type. Any value type except Nullable\<T> can be specified.
37
36
38
37
You can also specify a generic parameter as a constraint. The type argument supplied for the type you are constraining must be or derive from the type of the constraint. This is called a naked type constraint.
39
38
@@ -44,9 +43,9 @@ where type-parameter: constraint list
44
43
45
44
Class and interface constraints specify that the argument types must be or inherit from a specified class or implement a specified interface.
46
45
47
-
The application of constraints to a generic type or method allows code in that type or method to take advantage of the known features of the constrained types. For example, you can declare a generic class such that the type parameter implements the **IComparable\<T>** interface:
46
+
The application of constraints to a generic type or method allows code in that type or method to take advantage of the known features of the constrained types. For example, you can declare a generic class such that the type parameter implements the `IComparable<T>` interface:
48
47
49
-
```
48
+
```cpp
50
49
// generics_constraints_1.cpp
51
50
// compile with: /c /clr
52
51
usingnamespaceSystem;
@@ -55,17 +54,17 @@ where T : IComparable<T>
55
54
ref classList {};
56
55
```
57
56
58
-
This constraint requires that a type argument used for `T` implements `IComparable<T>` at compile time. It also allows interface methods, such as **CompareTo**, to be called. No cast is needed on an instance of the type parameter to call interface methods.
57
+
This constraint requires that a type argument used for `T` implements `IComparable<T>` at compile time. It also allows interface methods, such as `CompareTo`, to be called. No cast is needed on an instance of the type parameter to call interface methods.
59
58
60
59
Static methods in the type argument's class cannot be called through the type parameter; they can be called only through the actual named type.
61
60
62
-
A constraint cannot be a value type, including built-in types such as `int` or **double**. Since value types cannot have derived classes, only one class would ever be able to satisfy the constraint. In that case, the generic can be rewritten with the type parameter replaced by the specific value type.
61
+
A constraint cannot be a value type, including built-in types such as **int** or **double**. Since value types cannot have derived classes, only one class would ever be able to satisfy the constraint. In that case, the generic can be rewritten with the type parameter replaced by the specific value type.
63
62
64
63
Constraints are required in some cases since the compiler will not allow the use of methods or other features of an unknown type unless the constraints imply that the unknown type supports the methods or interfaces.
65
64
66
65
Multiple constraints for the same type parameter can be specified in a comma-separated list
67
66
68
-
```
67
+
```cpp
69
68
// generics_constraints_2.cpp
70
69
// compile with: /c /clr
71
70
using namespace System;
@@ -77,7 +76,7 @@ ref class List {};
77
76
78
77
With multiple type parameters, use one **where** clause for each type parameter. For example:
79
78
80
-
```
79
+
```cpp
81
80
// generics_constraints_3.cpp
82
81
// compile with: /c /clr
83
82
usingnamespaceSystem;
@@ -97,7 +96,7 @@ ref class Dictionary {};
97
96
98
97
- Constraints cannot themselves be type parameters, but they can involve the type parameters in an open constructed type. For example:
99
98
100
-
```
99
+
```cpp
101
100
// generics_constraints_4.cpp
102
101
// compile with: /c /clr
103
102
generic <typename T>
@@ -111,7 +110,7 @@ ref class Dictionary {};
111
110
## Example
112
111
The following example demonstrates using constraints to call instance methods on type parameters.
113
112
114
-
```
113
+
```cpp
115
114
// generics_constraints_5.cpp
116
115
// compile with: /clr
117
116
using namespace System;
@@ -172,11 +171,11 @@ int main() {
172
171
## Example
173
172
When a generic type parameter is used as a constraint, it is called a naked type constraint. Naked type constraints are useful when a member function with its own type parameter needs to constrain that parameter to the type parameter of the containing type.
174
173
175
-
In the following example, T is a naked type constraint in the context of the Add method.
174
+
In the following example, `T` is a naked type constraint in the context of the `Add` method.
176
175
177
176
Naked type constraints can also be used in generic class definitions. The usefulness of naked type constraints with generic classes is limited because the compiler can assume nothing about a naked type constraint except that it derives from <xref:System.Object>. Use naked type constraints on generic classes in scenarios in which you wish to enforce an inheritance relationship between two type parameters.
The following code example shows that in the appropriate context, the `property` context-sensitive keyword can be used to define a property and a variable.
68
+
The following code example shows that in the appropriate context, the **property** context-sensitive keyword can be used to define a property and a variable.
Specifies that the user-defined type is a control.
17
-
18
-
## Syntax
19
-
20
-
```
21
-
22
-
[control]
23
-
24
-
```
25
-
26
-
## Remarks
27
-
The **control** attribute implies the [coclass](../windows/coclass.md) attribute. The **control** C++ attribute has the same functionality as the [control](http://msdn.microsoft.com/library/windows/desktop/aa366764) MIDL attribute.
[Typedef, Enum, Union, and Struct Attributes](../windows/typedef-enum-union-and-struct-attributes.md)
1
+
---
2
+
title: "control | Microsoft Docs"
3
+
ms.custom: ""
4
+
ms.date: "11/04/2016"
5
+
ms.technology: ["cpp-windows"]
6
+
ms.topic: "reference"
7
+
f1_keywords: ["vc-attr.control"]
8
+
dev_langs: ["C++"]
9
+
helpviewer_keywords: ["Control attribute"]
10
+
ms.assetid: 3d046bb2-4afe-4cb8-a762-233b296e1975
11
+
author: "mikeblome"
12
+
ms.author: "mblome"
13
+
ms.workload: ["cplusplus", "uwp"]
14
+
---
15
+
# control
16
+
Specifies that the user-defined type is a control.
17
+
18
+
## Syntax
19
+
20
+
```
21
+
[control]
22
+
```
23
+
24
+
## Remarks
25
+
The **control** attribute implies the [coclass](../windows/coclass.md) attribute. The **control** C++ attribute has the same functionality as the [control](http://msdn.microsoft.com/library/windows/desktop/aa366764) MIDL attribute.
Provides links to topics describing the C and C++ language references, the libraries provided with Visual C++, the Visual C++ Extensibility Object Model, and the Microsoft Macro Assembler (MASM).
0 commit comments