Skip to content

Commit e2be815

Browse files
authored
Update 006_variant_bad_variant_access.cpp
1 parent 3bec838 commit e2be815

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
1
1+
#include <variant>
2+
#include <iostream>
3+
4+
int main()
5+
{
6+
std::variant<int, float> v;
7+
v = 12;
8+
try {
9+
std::get<float>(v);
10+
}
11+
catch(const std::bad_variant_access& e) {
12+
std::cout << e.what() << '\n';
13+
}
14+
}

0 commit comments

Comments
 (0)