Skip to content

Commit a27121d

Browse files
Colin RobertsonTylerMSFT
andauthored
Add content missing from <any> docs, update style (#2969)
* Test of library style changes * Horizontal rule test * Moar standardization experiments * Remove unused html tag from markdownlint * Possibly spurious H1 complaint? * Fix merge issue * Style tweaks, de-dup descriptions * Attempt to match .NET docs style * Revert some changes per style guide * Update any-functions.md fixed a title. Co-authored-by: Tyler Whitney <[email protected]>
1 parent 00f2128 commit a27121d

File tree

4 files changed

+132
-71
lines changed

4 files changed

+132
-71
lines changed

docs/standard-library/any-class.md

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,48 @@
11
---
2-
description: "Learn more about: any Class"
3-
title: "any Class"
4-
ms.date: "04/04/2019"
2+
description: "Learn more about the std::any class from the C++ Standard Library."
3+
title: "any class"
4+
ms.date: 09/20/2021
55
f1_keywords: ["any/std::any", "any/std::any::emplace", "any/std::any::has_value", "any/std::any::reset", "any/std::any::swap", "any/std::any::type"]
66
helpviewer_keywords: ["any/std::any", "any/std::any::emplace", "any/std::any::has_value", "any/std::any::reset", "any/std::any::swap", "any/std::any::type"]
7+
no-loc: ["any", "std", "class"]
78
---
8-
# any Class
9+
# `any` class
910

10-
Stores an instance of any type that satisfies the constructor requirements or it has no value, which is called the state of the class any object.
11+
An `any` object either stores an instance of a type that satisfies the constructor requirements, or it has no value. Whether it has a stored instance, or no value, is called the *state* of the `any` object.
1112

12-
The stored instance is called the contained value. Two states are the same if either they both have no value, or both have a value and the contained values are the same.
13+
The stored instance is called the *contained value*. Two `any` objects have the same state if either they both have no value, or both have a contained value and those values are the same.
1314

1415
## Syntax
1516

1617
```cpp
17-
class any
18+
class any;
1819
```
1920

2021
## Members
2122

2223
### Constructors
2324

24-
|Name|Description|
25-
|-|-|
26-
|[any](#any)|Constructs an object of type `any`.|
25+
| Name | Description |
26+
|--|--|
27+
| [`any`](#any) | Constructs an object of type `any`. |
2728

2829
### Functions
2930

30-
|Name|Description|
31-
|-|-|
32-
|[emplace](#emplace)|Sets an any value.|
33-
|[has_value](#has_value)|Returns **`true`** if any has a value.|
34-
|[reset](#reset)|Resets an any.|
35-
|[swap](#swap)|Swaps two any objects.|
36-
|[type](#type)|Returns the any type.|
31+
| Name | Description |
32+
|--|--|
33+
| [`emplace`](#emplace) | Sets an `any` value. |
34+
| [`has_value`](#has_value) | Returns **`true`** if `any` has a value. |
35+
| [`reset`](#reset) | Resets an `any`. |
36+
| [`swap`](#swap) | Exchanges two `any` objects. |
37+
| [`type`](#type) | Returns the `any` type. |
3738

3839
### Operators
3940

40-
|Name|Description|
41-
|-|-|
42-
|[operator=](#op_eq)|Replaces the any with a copy of another any.|
41+
| Name | Description |
42+
|--|--|
43+
| [`operator=`](#op_eq) | Replaces the `any` with a copy of another `any`. |
4344

44-
## <a name="any"></a> any
45+
## <a name="any"></a> `any`
4546

4647
Constructs an object of type `any`. Also includes a destructor.
4748

@@ -59,9 +60,9 @@ template <class T, class U, class... Args>
5960
~any();
6061
```
6162
62-
## <a name="emplace"></a> emplace
63+
## <a name="emplace"></a> `emplace`
6364
64-
Sets an any value.
65+
Sets an `any` value.
6566
6667
```cpp
6768
template <class T, class... Args>
@@ -70,17 +71,17 @@ template <class T, class U, class... Args>
7071
decay_t<T>& emplace(initializer_list<U>, Args&&...);
7172
```
7273

73-
## <a name="has_value"></a> has_value
74+
## <a name="has_value"></a> `has_value`
7475

75-
Returns **`true`** if any has a value.
76+
Returns **`true`** if the `any` object has a value.
7677

7778
```cpp
7879
bool has_value() const noexcept;
7980
```
8081

81-
## <a name="op_eq"></a> operator=
82+
## <a name="op_eq"></a> `operator=`
8283

83-
Replaces the any with a copy of another any.
84+
Replaces the `any` content with a copy of another `any`.
8485

8586
```cpp
8687
any& operator=(const any& right);
@@ -91,29 +92,45 @@ template <class T>
9192

9293
### Parameters
9394

94-
*right*\
95-
The any being copied into the any.
95+
*`right`*\
96+
The `any` being copied into this `any`.
9697

97-
## <a name="reset"></a> reset
98+
## <a name="reset"></a> `reset`
9899

99-
Resets an any.
100+
Resets an `any`.
100101

101102
```cpp
102103
void reset() noexcept;
103104
```
104105

105-
## <a name="swap"></a> swap
106+
## <a name="swap"></a> `swap`
106107

107-
Swaps two any objects.
108+
Exchanges two `any` objects.
108109

109110
```cpp
110111
void swap(any& rhs) noexcept;
111112
```
112113
113-
## <a name="type"></a> type
114+
## <a name="type"></a> `type`
114115
115-
Returns the any type.
116+
Returns the `any` type.
116117
117118
```cpp
118119
const type_info& type() const noexcept;
119120
```
121+
122+
## Requirements
123+
124+
**Header:** \<any>
125+
126+
**Namespace:** `std`
127+
128+
**Standard:** C++17 (Use at least **`/std:c++17`** to compile.)
129+
130+
## See also
131+
132+
[`<any>`](any.md)\
133+
[`any_cast`](any-functions.md#any_cast)\
134+
[`make_any`](any-functions.md#make_any)\
135+
[`swap`](any-functions.md#swap)\
136+
[`bad_any_cast`](bad-any-cast-class.md)
Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
---
2-
description: "Learn more about: &lt;any&gt; functions"
2+
description: "Learn more about the free functions for use with the std::any class in the C++ Standard Library."
33
title: "&lt;any&gt; functions"
4-
ms.date: "04/04/2019"
4+
ms.date: 09/20/2021
55
f1_keywords: ["any/std::any_cast", "any/std::make_any", "any/std::swap"]
6+
no-loc: ["any", "std", "class"]
67
---
7-
# &lt;any&gt; functions
8+
# `<any>` functions
89

9-
## <a name="any_cast"></a> any_cast
10+
The [`<any>`](any.md) header declares several free functions for working with the [`any`](any-class.md) class.
1011

11-
Makes an object into an any.
12+
## Functions
13+
14+
| &nbsp; | &nbsp; |
15+
|--|--|
16+
| [`any_cast`](#any_cast) | Makes an object into an `any`. |
17+
| [`make_any`](#make_any) | Takes values and creates an `any` object. |
18+
| [`swap`](#swap) | Exchanges the elements of two `any` objects. |
19+
20+
## <a name="any_cast"></a> `any_cast`
21+
22+
Makes an object into an `any`.
1223

1324
```cpp
1425
template<class T>
@@ -23,9 +34,9 @@ template<class T>
2334
T* any_cast(any* operand) noexcept;
2435
```
2536
26-
## <a name="make_any"></a> make_any
37+
## <a name="make_any"></a> `make_any`
2738
28-
Takes values and creates an any object.
39+
Takes values and creates an `any` object.
2940
3041
```cpp
3142
template <class T, class... Args>
@@ -34,18 +45,32 @@ template <class T, class U, class... Args>
3445
any make_any(initializer_list<U> il, Args&& ...args);
3546
```
3647

37-
## <a name="swap"></a> swap
48+
## <a name="swap"></a> `swap`
3849

39-
Exchanges the elements of two objects any.
50+
Exchanges the elements of two `any` objects.
4051

4152
```cpp
4253
void swap(any& left, any& right) noexcept;
4354
```
4455
4556
### Parameters
4657
47-
*left*\
58+
*`left`*\
4859
An object of type `any`.
4960
50-
*right*\
61+
*`right`*\
5162
An object of type `any`.
63+
64+
## Requirements
65+
66+
**Header:** \<any>
67+
68+
**Namespace:** `std`
69+
70+
**Standard:** C++17 (Use at least **`/std:c++17`** to compile.)
71+
72+
## See also
73+
74+
[`<any>`](any.md)\
75+
[`any` class](any-class.md)\
76+
[`bad_any_cast`](bad-any-cast-class.md)

docs/standard-library/any.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,40 @@
11
---
2-
description: "Learn more about: &lt;any&gt;"
2+
description: "Learn more about the classes and functions declared in the <any> header in the C++ Standard Library."
33
title: "&lt;any&gt;"
4-
ms.date: "04/04/2019"
4+
ms.date: 09/20/2021
55
f1_keywords: ["<any>"]
66
helpviewer_keywords: ["<any>"]
7+
no-loc: ["any", "std", "class"]
78
---
89
# &lt;any&gt;
910

10-
Defines the class any and several supporting functions and classes.
11+
Defines the class `std::any` and several supporting functions and classes.
1112

1213
## Requirements
1314

1415
**Header:** \<any>
1516

16-
**Namespace:** std
17+
**Namespace:** `std`
18+
19+
**Standard:** C++17 (Use at least **`/std:c++17`** to compile.)
1720

1821
## Members
1922

2023
### Functions
2124

22-
|Name|Description|
23-
|-|-|
24-
|[any_cast](../standard-library/any-functions.md#any_cast)|Makes an object into an any.|
25-
|[make_any](../standard-library/any-functions.md#make_any)|Takes values and creates an any object.|
26-
|[swap](../standard-library/any-functions.md#swap)|Exchanges the elements of two objects any.|
25+
| Name | Description |
26+
|--|--|
27+
| [`any_cast`](../standard-library/any-functions.md#any_cast) | Makes an object into an `any`. |
28+
| [`make_any`](../standard-library/any-functions.md#make_any) | Takes values and creates an `any` object. |
29+
| [`swap`](../standard-library/any-functions.md#swap) | Exchanges the elements of two `any` objects. |
2730

2831
### Classes
2932

30-
|Name|Description|
31-
|-|-|
32-
|[any](../standard-library/any-class.md)|Stores any type that satisfies the constructor requirements or has no value.|
33-
|[bad_any_cast](../standard-library/bad-any-cast-class.md)|Objects thrown by a failed `any_cast`.|
33+
| Name | Description |
34+
|--|--|
35+
| [`any`](../standard-library/any-class.md) | An `any` instance either stores a type that satisfies the constructor requirements or has no value. |
36+
| [`bad_any_cast`](../standard-library/bad-any-cast-class.md) | Objects thrown by a failed `any_cast`. |
3437

3538
## See also
3639

37-
[Header Files Reference](../standard-library/cpp-standard-library-header-files.md)
40+
[Header files reference](../standard-library/cpp-standard-library-header-files.md)
Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,46 @@
11
---
2-
description: "Learn more about: bad_any_cast Class"
3-
title: "bad_any_cast Class"
4-
ms.date: "04/04/2019"
2+
description: "Learn more about the std::bad_any_cast class from the C++ Standard Library."
3+
title: "bad_any_cast class"
4+
ms.date: 09/20/2021
55
f1_keywords: ["any/std::bad_any_cast", "any/std::bad_any_cast::what"]
66
helpviewer_keywords: ["any/std::bad_any_cast", "any/std::bad_any_cast::what"]
7+
no-loc: ["any", "std", "class", "what"]
78
---
8-
# bad_any_cast Class
9+
# `bad_any_cast` class
910

10-
Objects thrown by a failed `any_cast`.
11+
Objects thrown by a failed [`any_cast`](any-functions.md#any_cast).
1112

1213
## Syntax
1314

1415
```cpp
15-
class bad_any_cast
16+
class bad_any_cast ;
1617
```
1718
18-
### Member functions
19+
## Members
1920
20-
|Name|Description|
21-
|-|-|
22-
|[what](#what)|Returns the type.|
21+
| Name | Description |
22+
|--|--|
23+
| [`what`](#what) | Returns the type. |
2324
24-
## <a name="what"></a> what
25+
## <a name="what"></a> `bad_any_cast::what`
2526
2627
Returns the type.
2728
2829
```cpp
2930
const char* what() const noexcept override;
3031
```
32+
33+
## Requirements
34+
35+
**Header:** \<any>
36+
37+
**Namespace:** `std`
38+
39+
**Standard:** C++17 (Use at least **`/std:c++17`** to compile.)
40+
41+
## See also
42+
43+
[`<any>`](any.md)\
44+
[`any` class](any-class.md)\
45+
[`any_cast`](any-functions.md#any_cast)\
46+
[`exception`](exception-class.md)

0 commit comments

Comments
 (0)