-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVariant.cpp
39 lines (28 loc) · 847 Bytes
/
Variant.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* \file main.cpp
* \brief std::variant
*
* \todo
*
* The class template std::variant represents a type-safe union. An instance of std::variant
* at any given time holds a value of one of its alternative types (it's also possible for it
* to be valueless).
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//-------------------------------------------------------------------------------------------------
int main(int, char **)
{
std::variant<int, double> v{ 12 };
std::get<int>(v); // == 12
std::get<0>(v); // == 12
v = 12.0;
std::get<double>(v); // == 12.0
std::get<1>(v); // == 12.0
// std::cout << STD_TRACE_VAR("") << std::endl;
return EXIT_SUCCESS;
}
//-------------------------------------------------------------------------------------------------
#if OUTPUT
#endif