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/cpp/attributes2.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,10 @@ void Foo(int);
26
26
-`carries_dependency`--specifies that the function propagates data dependency ordering with respect to thread synchronization. The attribute can be applied to one or more parameters, to specify that the passed-in argument carries a dependency into the function body. The attribute can be applied to the function itself, to specify that the return value carries a dependency out of the function. The compiler can use this information to generate more efficient code.
27
27
28
28
-`deprecated` – specifies that a function is not intended to be used, and might not exist in future versions of a library interface. The compiler can use this to generate an informational message when client code attempts to call the function. Can be applied to declaration of a class, a typedef-name, a variable, a non-static data member, a function, a namespace, an enumeration, an enumerator, or a template specialization.
29
+
30
+
-`fallthrough` - **Visual Studio 2017 and later:**(available with [/std:c++latest](../build/reference/std-specify-language-standard-version.md)) The `[[fallthrough]]` attribute can be used in the context of [switch](switch-statement-cpp.md) statements as a hint to the compiler (or anyone reading the code) that the fallthrough behavior is intended. The Visual C++ compiler currently does not warn on fallthrough behavior, so this attribute has no effect compiler behavior.
31
+
32
+
**Microsoft-specific:**
29
33
30
34
-`gsl::suppress` -- this Microsoft-specific attribute is used for suppressing warnings from checkers that enforce [Guidelines Support Library (GSL)](https://github.com/Microsoft/GSL) rules in code. For example, consider the code snippet below
Copy file name to clipboardExpand all lines: docs/cpp/range-based-for-statement-cpp.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,9 +42,11 @@ Executes `statement` repeatedly and sequentially for each element in `expression
42
42
```
43
43
44
44
## Remarks
45
-
Use the range-based `for` statement to construct loops that must execute through a "range", which is defined as anything that you can iterate through—for example, `std::vector`, or any other C++ Standard Library sequence whose range is defined by a `begin()` and `end()`. The name that is declared in the `for-range-declaration` portion is local to the `for` statement and cannot be re-declared in `expression` or `statement`. Note that the [auto](../cpp/auto-cpp.md) keyword is preferred in the `for-range-declaration` portion of the statement.
45
+
Use the range-based `for` statement to construct loops that must execute through a "range", which is defined as anything that you can iterate through—for example, `std::vector`, or any other C++ Standard Library sequence whose range is defined by a `begin()` and `end()`. The name that is declared in the `for-range-declaration` portion is local to the `for` statement and cannot be re-declared in `expression` or `statement`. Note that the [auto](../cpp/auto-cpp.md) keyword is preferred in the `for-range-declaration` portion of the statement.
46
+
47
+
**New in Visual Studio 2017:** Range-based for loops no longer require that begin() and end() return objects of the same type. This enables end() to return a sentinel object such as used by ranges as defined in the Ranges-V3 proposal. For more information, see [Generalizing the Range-Based For Loop](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0184r0.html) and the [range-v3 library on GitHub](https://github.com/ericniebler/range-v3).
46
48
47
-
This code shows how to use ranged`for` loops to iterate through an array and a vector:
49
+
This code shows how to use range-based`for` loops to iterate through an array and a vector:
48
50
49
51
```cpp
50
52
// range-based-for.cpp
@@ -78,7 +80,7 @@ int main()
78
80
}
79
81
cout << endl;
80
82
81
-
for( const auto &y : x ) { // Type inference by reference.
83
+
for( const auto &y : x ) { // Type inference by const reference.
82
84
// Observes in-place. Preferred when no modify is needed.
Copy file name to clipboardExpand all lines: docs/cpp/switch-statement-cpp.md
+32-3Lines changed: 32 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,11 +99,39 @@ int main() {
99
99
}
100
100
```
101
101
102
-
In the above example, `capa` is incremented if `c` is an uppercase `A`. The `break` statement after `capa++` terminates execution of the `switch` statement body and control passes to the `while` loop. Without the `break` statement, `lettera` and `nota` would also be incremented. A similar purpose is served by the `break` statement for `case 'a'`. If `c` is a lowercase `a`, `lettera` is incremented and the `break` statement terminates the `switch` statement body. If `c` is not an `a` or `A`, the `default` statement is executed.
102
+
In the above example, `capa` is incremented if `c` is an uppercase `A`. The `break` statement after `capa++` terminates execution of the `switch` statement body and control passes to the `while` loop. Without the `break` statement, execution would "fall through" to the next labeled statement, so that `lettera` and `nota` would also be incremented. A similar purpose is served by the `break` statement for `case 'a'`. If `c` is a lowercase `a`, `lettera` is incremented and the `break` statement terminates the `switch` statement body. If `c` is not an `a` or `A`, the `default` statement is executed.
103
+
104
+
**Visual Studio 2017 and later:** (available with [/std:c++latest](../build/reference/std-specify-language-standard-version.md)) The `[[fallthrough]]` attribute is specified in the C++17 standard. It can be used in a `switch` statement as a hint to the compiler (or to anyone reading the code) that fall-through behavior is intended. The Visual C++ compiler currently does not warn on fallthrough behavior, so this attribute has no effect compiler behavior. Note that the attribute is applied to an empty statement within the labeled statement; in other words the semicolon is necessary.
105
+
106
+
```cpp
107
+
intmain()
108
+
{
109
+
int n = 5;
110
+
switch (n)
111
+
{
112
+
113
+
case 1:
114
+
a();
115
+
break;
116
+
case 2:
117
+
b();
118
+
d();
119
+
[[fallthrough]]; // I meant to do this!
120
+
case 3:
121
+
c();
122
+
break;
123
+
default:
124
+
d();
125
+
break;
126
+
}
127
+
128
+
return 0;
129
+
}
130
+
```
103
131
104
132
An inner block of a `switch` statement can contain definitions with initializations as long as they are reachable — that is, not bypassed by all possible execution paths. Names introduced using these declarations have local scope. For example:
105
133
106
-
```
134
+
```cpp
107
135
// switch_statement2.cpp
108
136
// C2360 expected
109
137
#include<iostream>
@@ -137,7 +165,8 @@ int main(int argc, char *argv[])
137
165
```
138
166
139
167
A `switch` statement can be nested. In such cases, **case** or **default** labels associate with the closest `switch` statement that encloses them.
140
-
168
+
169
+
141
170
## Microsoft Specific
142
171
Microsoft C does not limit the number of case values in a `switch` statement. The number is limited only by the available memory. ANSI C requires at least 257 case labels be allowed in a `switch` statement.
Copy file name to clipboardExpand all lines: docs/cppcx/platform-agile-class.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -154,7 +154,7 @@ throw();
154
154
### Remarks
155
155
This operation releases the current representation of a object of type `T`, if any; reinitializes the Agile object's data members; acquires the current threading context; and then returns the address of a handle-to-object variable that can represent a non-agile object. To cause an Agile class instance to represent an object, use the assignment operator ([Agile::operator=](#operator-assign)) to assign the object to the Agile class instance.
Returns a read-only view of the current Map; that is, a [Platform::Collections::MapView Class](../cppcx/platform-collections-mapview-class.md), which implements the [Windows::Foundation::Collections::IMapView\<K,V>](http://msdn.microsoft.com/library/windows/apps/br226037.aspx) interface.
Deletes the specified key-value pair from the current Map object.
257
257
258
258
### Syntax
@@ -267,7 +267,7 @@ virtual void Remove(K key);
267
267
268
268
269
269
270
-
## <a name="size"</a> Map::Size Method
270
+
## <aname="size"></a> Map::Size Method
271
271
Returns the number of [Windows::Foundation::Collections::IKeyValuePair\<K,V>](http://msdn.microsoft.com/library/windows/apps/br226031.aspx) elements in the Map.
Copy file name to clipboardExpand all lines: docs/cppcx/platform-collections-vectorviewiterator-class.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,7 +67,7 @@ class VectorViewIterator;
67
67
|[VectorViewIterator::operator+= Operator](#operator-plus-assign)|Increments the current VectorViewIterator by the specified displacement.|
68
68
|[VectorViewIterator::operator< Operator](#operator-less-than)|Indicates whether the current VectorViewIterator is less than a specified VectorViewIterator.|
69
69
|[VectorViewIterator::operator\<= Operator](#operator-less-than-or-equals)|Indicates whether the current VectorViewIterator is less than or equal to a specified VectorViewIterator.|
70
-
|[VectorViewIterator::operator-= Operator](#operator-subtract-assign)|Decrements the current VectorViewIterator by the specified displacement.|
70
+
|[VectorViewIterator::operator-= Operator](#operator-minus-assign)|Decrements the current VectorViewIterator by the specified displacement.|
71
71
|[VectorViewIterator::operator== Operator](#operator-equality)|Indicates whether the current VectorViewIterator is equal to a specified VectorViewIterator.|
72
72
|[VectorViewIterator::operator> Operator](#operator-greater-than)|Indicates whether the current VectorViewIterator is greater than a specified VectorViewIterator.|
73
73
|[VectorViewIterator::operator-> Operator](#operator-arrow)|Retrieves the address of the element referenced by the current VectorViewIterator.|
0 commit comments