Skip to content

Commit 24f54ae

Browse files
author
msebolt
committed
revision completed
1 parent 25073f3 commit 24f54ae

File tree

8 files changed

+155
-1320
lines changed

8 files changed

+155
-1320
lines changed

docs/standard-library/bad-variant-access-class.md

Lines changed: 8 additions & 957 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,26 @@
11
---
2-
title: "type_index Class"
3-
ms.date: "11/04/2016"
4-
f1_keywords: ["typeindex/std::type_index"]
5-
helpviewer_keywords: ["type_index class"]
6-
ms.assetid: db366119-74cb-43e8-aacf-9679e561fa2f
2+
title: "monostate Struct"
3+
ms.date: "04/04/2019"
4+
f1_keywords: ["variant/std::monostate"]
5+
helpviewer_keywords: ["monostate struct"]
76
---
7+
# monostate Struct
88

9-
// 23.7.8, class monostate
9+
The class monostate serves as the alternative type for a variant to make the variant type default constructible.
10+
11+
## Syntax
12+
13+
```cpp
1014
struct monostate;
11-
// 23.7.9, monostate relational operators
15+
1216
constexpr bool operator<(monostate, monostate) noexcept;
1317
constexpr bool operator>(monostate, monostate) noexcept;
1418
constexpr bool operator<=(monostate, monostate) noexcept;
1519
constexpr bool operator>=(monostate, monostate) noexcept;
1620
constexpr bool operator==(monostate, monostate) noexcept;
1721
constexpr bool operator!=(monostate, monostate) noexcept;
18-
# type_index Class
19-
20-
template <class T>
21-
struct variant_size; // not defined
22-
template <class T>
23-
struct variant_size<const T>;
24-
template <class T>
25-
struct variant_size<volatile T>;
26-
template <class T>
27-
struct variant_size<const volatile T>;
28-
template <class T>
29-
inline constexpr size_t variant_size_v = variant_size<T>::value;
30-
template <class... Types>
31-
struct variant_size<variant<Types...>>;
32-
33-
The `type_index` class wraps a pointer to [type_info Class](../cpp/type-info-class.md) to assist in indexing by such objects.
34-
35-
class type_index {
36-
public:
37-
type_index(const type_info& tinfo);
38-
const char *name() const;
39-
size_t hash_code() const;
40-
bool operator==(const type_info& right) const;
41-
bool operator!=(const type_info& right) const;
42-
bool operator<(const type_info& right) const;
43-
bool operator\<=(const type_info& right) const;
44-
bool operator>(const type_info& right) const;
45-
bool operator>=(const type_info& right) const;
46-
};
47-
48-
The constructor initializes `ptr` to `&tinfo`.
49-
50-
`name` returns `ptr->name()`.
51-
52-
`hash_code` returns `ptr->hash_code().`
53-
54-
`operator==` returns `*ptr == right.ptr`.
55-
56-
`operator!=` returns `!(*this == right)`.
57-
58-
`operator<` returns `*ptr->before(*right.ptr)`.
59-
60-
`operator<=` returns `!(right < *this).`
61-
62-
`operator>` returns `right < *this`.
63-
64-
`operator>=` returns `!(*this < right)`.
22+
```
6523

6624
## See also
6725

68-
[Run-Time Type Information](../cpp/run-time-type-information.md)<br/>
69-
[\<typeindex>](../standard-library/typeindex.md)<br/>
26+
[&lt;variant>](../standard-library/variant.md)
Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,30 @@
11
---
2-
title: "type_index Class"
3-
ms.date: "11/04/2016"
4-
f1_keywords: ["typeindex/std::type_index"]
5-
helpviewer_keywords: ["type_index class"]
6-
ms.assetid: db366119-74cb-43e8-aacf-9679e561fa2f
2+
title: "variant_alternative Struct"
3+
ms.date: "04/04/2019"
4+
f1_keywords: ["variant/std::variant_alternative"]
5+
helpviewer_keywords: ["variant_alternative struct"]
76
---
8-
# type_index Class
7+
# variant_alternative Struct
98

9+
Assists the variant objects.
10+
11+
## Syntax
12+
13+
```cpp
1014
template <size_t I, class T>
11-
struct variant_alternative; // not defined
15+
struct variant_alternative; // not defined
1216
template <size_t I, class T>
13-
struct variant_alternative<I, const T>;
17+
struct variant_alternative<I, const T>;
1418
template <size_t I, class T>
15-
struct variant_alternative<I, volatile T>;
19+
struct variant_alternative<I, volatile T>;
1620
template <size_t I, class T>
17-
struct variant_alternative<I, const volatile T>;
21+
struct variant_alternative<I, const volatile T>;
1822
template <size_t I, class T>
19-
using variant_alternative_t = typename variant_alternative<I, T>::type;
23+
using variant_alternative_t = typename variant_alternative<I, T>::type;
2024
template <size_t I, class... Types>
21-
struct variant_alternative<I, variant<Types...>>;
22-
23-
The `type_index` class wraps a pointer to [type_info Class](../cpp/type-info-class.md) to assist in indexing by such objects.
24-
25-
class type_index {
26-
public:
27-
type_index(const type_info& tinfo);
28-
const char *name() const;
29-
size_t hash_code() const;
30-
bool operator==(const type_info& right) const;
31-
bool operator!=(const type_info& right) const;
32-
bool operator<(const type_info& right) const;
33-
bool operator\<=(const type_info& right) const;
34-
bool operator>(const type_info& right) const;
35-
bool operator>=(const type_info& right) const;
36-
};
37-
38-
The constructor initializes `ptr` to `&tinfo`.
39-
40-
`name` returns `ptr->name()`.
41-
42-
`hash_code` returns `ptr->hash_code().`
43-
44-
`operator==` returns `*ptr == right.ptr`.
45-
46-
`operator!=` returns `!(*this == right)`.
47-
48-
`operator<` returns `*ptr->before(*right.ptr)`.
49-
50-
`operator<=` returns `!(right < *this).`
51-
52-
`operator>` returns `right < *this`.
53-
54-
`operator>=` returns `!(*this < right)`.
25+
struct variant_alternative<I, variant<Types...>>;
26+
```
5527
5628
## See also
5729
58-
[Run-Time Type Information](../cpp/run-time-type-information.md)<br/>
59-
[\<typeindex>](../standard-library/typeindex.md)<br/>
30+
[&lt;variant>](../standard-library/variant.md)
Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
---
22
title: "variant Class"
3-
ms.date: "11/04/2016"
4-
f1_keywords: ["forward_list/std::forward_list", "forward_list/std::forward_list::allocator_type", "forward_list/std::forward_list::const_iterator", "forward_list/std::forward_list::const_pointer", "forward_list/std::forward_list::const_reference", "forward_list/std::forward_list::difference_type", "forward_list/std::forward_list::iterator", "forward_list/std::forward_list::pointer", "forward_list/std::forward_list::reference", "forward_list/std::forward_list::size_type", "forward_list/std::forward_list::value_type", "forward_list/std::forward_list::assign", "forward_list/std::forward_list::before_begin", "forward_list/std::forward_list::begin", "forward_list/std::forward_list::cbefore_begin", "forward_list/std::forward_list::cbegin", "forward_list/std::forward_list::cend", "forward_list/std::forward_list::clear", "forward_list/std::forward_list::emplace_after", "forward_list/std::forward_list::emplace_front", "forward_list/std::forward_list::empty", "forward_list/std::forward_list::end", "forward_list/std::forward_list::erase_after", "forward_list/std::forward_list::front", "forward_list/std::forward_list::get_allocator", "forward_list/std::forward_list::insert_after", "forward_list/std::forward_list::max_size", "forward_list/std::forward_list::merge", "forward_list/std::forward_list::pop_front", "forward_list/std::forward_list::push_front", "forward_list/std::forward_list::remove", "forward_list/std::forward_list::remove_if", "forward_list/std::forward_list::resize", "forward_list/std::forward_list::reverse", "forward_list/std::forward_list::sort", "forward_list/std::forward_list::splice_after", "forward_list/std::forward_list::swap", "forward_list/std::forward_list::unique"]
5-
helpviewer_keywords: ["std::forward_list", "std::forward_list::allocator_type", "std::forward_list::const_iterator", "std::forward_list::const_pointer", "std::forward_list::const_reference", "std::forward_list::difference_type", "std::forward_list::iterator", "std::forward_list::pointer", "std::forward_list::reference", "std::forward_list::size_type", "std::forward_list::value_type", "std::forward_list::assign", "std::forward_list::before_begin", "std::forward_list::begin", "std::forward_list::cbefore_begin", "std::forward_list::cbegin", "std::forward_list::cend", "std::forward_list::clear", "std::forward_list::emplace_after", "std::forward_list::emplace_front", "std::forward_list::empty", "std::forward_list::end", "std::forward_list::erase_after", "std::forward_list::front", "std::forward_list::get_allocator", "std::forward_list::insert_after", "std::forward_list::max_size", "std::forward_list::merge", "std::forward_list::pop_front", "std::forward_list::push_front", "std::forward_list::remove", "std::forward_list::remove_if", "std::forward_list::resize", "std::forward_list::reverse", "std::forward_list::sort", "std::forward_list::splice_after", "std::forward_list::swap", "std::forward_list::unique"]
3+
ms.date: "04/04/2019"
4+
f1_keywords: ["variant/std::variant", "variant/std::variant::emplace", "variant/std::variant::index", "variant/std::variant::valueless_by_exception"]
5+
helpviewer_keywords: ["variant/std::variant", "variant/std::variant::emplace", "variant/std::variant::index", "variant/std::variant::valueless_by_exception"]
66
---
77
# variant Class
88

99
Any instance of variant at any given time either holds a value of one of its alternative types, or it holds no value.
1010

11-
namespace std {
12-
template <class... Types>
13-
class variant {
14-
15-
// 23.7.3.5, value status
16-
17-
constexpr size_t index() const noexcept;
18-
};
19-
}
20-
2111
## Syntax
2212

2313
```cpp
24-
template <class Type,
25-
class Allocator = allocator<Type>>
26-
class forward_list
14+
template <class... Types>
15+
class variant
2716
```
2817
2918
### Constructors
@@ -36,9 +25,9 @@ class forward_list
3625
3726
|Member function|Description|
3827
|-|-|
39-
|[emplace](#emplace)|Erases elements from a forward list and copies a new set of elements to a target forward list.|
40-
|[index](#index)|Erases elements from a forward list and copies a new set of elements to a target forward list.|
41-
|[valueless_by_exception](#emplace)|Erases elements from a forward list and copies a new set of elements to a target forward list.|
28+
|[emplace](#emplace)|Creates a new contained value.|
29+
|[index](#index)|Returns the index of a contained value.|
30+
|[valueless_by_exception](#emplace)|Returns **false** if the variant holds a value.|
4231
4332
### Operators
4433
@@ -54,7 +43,7 @@ class forward_list
5443
5544
## <a name="emplace"></a> variant::emplace
5645
57-
No description.
46+
Creates a new contained value.
5847
5948
```cpp
6049
template <class T, class... Args>
@@ -69,10 +58,10 @@ template <size_t I, class U, class... Args>
6958

7059
## <a name="index"></a> variant::index
7160

72-
No description.
61+
Returns the index of a contained value.
7362

7463
```cpp
75-
64+
constexpr size_t index() const noexcept;
7665
```
7766

7867
## <a name="variant"></a> variant::variant
@@ -84,45 +73,39 @@ constexpr variant() noexcept(see below);
8473
variant(const variant&);
8574
variant(variant&&) noexcept(see below);
8675
template <class T>
87-
constexpr variant(T&&) noexcept(see below);
76+
constexpr variant(T&&) noexcept(see below);
8877
template <class T, class... Args>
89-
constexpr explicit variant(in_place_type_t<T>, Args&&...);
78+
constexpr explicit variant(in_place_type_t<T>, Args&&...);
9079
template <class T, class U, class... Args>
91-
constexpr explicit variant(in_place_type_t<T>, initializer_list<U>, Args&&...);
80+
constexpr explicit variant(in_place_type_t<T>, initializer_list<U>, Args&&...);
9281
template <size_t I, class... Args>
93-
constexpr explicit variant(in_place_index_t<I>, Args&&...);
82+
constexpr explicit variant(in_place_index_t<I>, Args&&...);
9483
template <size_t I, class U, class... Args>
95-
constexpr explicit variant(in_place_index_t<I>, initializer_list<U>, Args&&...);
96-
// allocator-extended constructors
84+
constexpr explicit variant(in_place_index_t<I>, initializer_list<U>, Args&&...);
85+
9786
template <class Alloc>
98-
variant(allocator_arg_t, const Alloc&);
87+
variant(allocator_arg_t, const Al&);
9988
template <class Alloc>
100-
variant(allocator_arg_t, const Alloc&, const variant&);
89+
variant(allocator_arg_t, const Al&, const variant&);
10190
template <class Alloc>
102-
variant(allocator_arg_t, const Alloc&, variant&&);
91+
variant(allocator_arg_t, const Al&, variant&&);
10392
template <class Alloc, class T>
104-
variant(allocator_arg_t, const Alloc&, T&&);
93+
variant(allocator_arg_t, const Al&, T&&);
10594
template <class Alloc, class T, class... Args>
106-
variant(allocator_arg_t, const Alloc&, in_place_type_t<T>, Args&&...);
95+
variant(allocator_arg_t, const Al&, in_place_type_t<T>, Args&&...);
10796
template <class Alloc, class T, class U, class... Args>
108-
variant(allocator_arg_t, const Alloc&, in_place_type_t<T>, initializer_list<U>, Args&&...);
97+
variant(allocator_arg_t, const Al&, in_place_type_t<T>, initializer_list<U>, Args&&...);
10998
template <class Alloc, size_t I, class... Args>
110-
variant(allocator_arg_t, const Alloc&, in_place_index_t<I>, Args&&...);
99+
variant(allocator_arg_t, const Al&, in_place_index_t<I>, Args&&...);
111100
template <class Alloc, size_t I, class U, class... Args>
112-
variant(allocator_arg_t, const Alloc&, in_place_index_t<I>, initializer_list<U>, Args&&...);
101+
variant(allocator_arg_t, const Al&, in_place_index_t<I>, initializer_list<U>, Args&&...);
113102
```
114103
115104
### Parameters
116105
117106
|Parameter|Description|
118107
|---------------|-----------------|
119108
|*Al*|The allocator class to use with this object.|
120-
|*Count*|The number of elements in the list constructed.|
121-
|*Val*|The value of the elements in the list constructed.|
122-
|*Right*|The list of which the constructed list is to be a copy.|
123-
|*First*|The position of the first element in the range of elements to be copied.|
124-
|*Last*|The position of the first element beyond the range of elements to be copied.|
125-
|*IList*|The initializer_list to copy.|
126109
127110
## <a name="op_eq"></a> variant::operator=
128111
@@ -137,12 +120,12 @@ template <class T>
137120

138121
## <a name="valueless"></a> variant::valueless_by_exception
139122

140-
No description.
123+
Returns **false** if the variant holds a value.
141124

142125
```cpp
143126
constexpr bool valueless_by_exception() const noexcept;
144127
```
145128

146129
## See also
147130

148-
[<variant>](../standard-library/variant.md)<br/>
131+
[<variant>](../standard-library/variant.md)

0 commit comments

Comments
 (0)