We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3bd55b0 commit 186e2bcCopy full SHA for 186e2bc
1 file changed
cpp_17/006_variant_get_if.cpp
@@ -1 +1,12 @@
1
-1
+#include <variant>
2
+#include <iostream>
3
+
4
+int main()
5
+{
6
+ std::variant<int, float> v{12};
7
8
+ if(auto pval = std::get_if<int>(&v))
9
+ std::cout << "variant value: " << *pval << '\n';
10
+ else
11
+ std::cout << "failed to get value!" << '\n';
12
+}
0 commit comments