-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAny.cpp
35 lines (24 loc) · 787 Bytes
/
Any.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
/**
* \file main.cpp
* \brief std::any
*
* \todo
*
* A type-safe container for single values of any type.
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//-------------------------------------------------------------------------------------------------
int main(int, char **)
{
std::any x {5};
std::cout << STD_TRACE_VAR(x.has_value()) << std::endl; // == true
std::cout << STD_TRACE_VAR(std::any_cast<int>(x)) << std::endl; // == 5
std::cout << STD_TRACE_VAR(std::any_cast<int&>(x)) << std::endl; // == 10;
std::cout << STD_TRACE_VAR(std::any_cast<int>(x)) << std::endl; // == 10
return EXIT_SUCCESS;
}
//-------------------------------------------------------------------------------------------------
#if OUTPUT
#endif