Added a test for eoOptional
This commit is contained in:
parent
290ff1cfd1
commit
7a0b889c3d
3 changed files with 36 additions and 2 deletions
29
eo/test/t-eoOptional.cpp
Normal file
29
eo/test/t-eoOptional.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// t-eoOptional.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "eoOptional.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef int T;
|
||||
|
||||
struct MyClass {
|
||||
MyClass(eoOptional<T> my_T = NULL)
|
||||
: default_T(42), actual_T(my_T.getOr(default_T))
|
||||
{
|
||||
std::cout << "Value " << actual_T << " was used for construction" << std::endl;
|
||||
}
|
||||
private:
|
||||
T default_T;
|
||||
T& actual_T;
|
||||
};
|
||||
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
// Three ways of using MyClass:
|
||||
MyClass mc1;
|
||||
MyClass mc2(NULL);
|
||||
T t(666);
|
||||
MyClass mc3(t);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue