mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-16 14:16:09 -06:00
New Core Tutorial
git-svn-id: svn://ultimatepp.org/upp/trunk@10538 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
dd88feaf2e
commit
6c22e727de
37 changed files with 3125 additions and 0 deletions
26
tutorial/CoreTutorial/Any.cpp
Normal file
26
tutorial/CoreTutorial/Any.cpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include "Tutorial.h"
|
||||
|
||||
void AnyTutorial()
|
||||
{
|
||||
/// .`Any`
|
||||
|
||||
/// `Any` is a container that can contain none or one element of %any% type. `Any::Is`
|
||||
/// method matches exact type ignoring class hierarchies (unlike `One::Is`). You can use
|
||||
/// `Get` to retrieve a reference to the instance stored:
|
||||
|
||||
for(int pass = 0; pass < 2; pass++) {
|
||||
Any x;
|
||||
if(pass)
|
||||
x.Create<String>() = "Hello!";
|
||||
else
|
||||
x.Create<Color>() = Blue();
|
||||
|
||||
if(x.Is<String>())
|
||||
LOG("Any is now String: " << x.Get<String>());
|
||||
|
||||
if(x.Is<Color>())
|
||||
LOG("Any is now Color: " << x.Get<Color>());
|
||||
}
|
||||
|
||||
///
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue