-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
35 lines (31 loc) · 725 Bytes
/
main.cpp
File metadata and controls
35 lines (31 loc) · 725 Bytes
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
//
// main.cpp
// switch
//
// Created by Sandy Martel on 5/1/17.
// Copyright © 2017 sandy. All rights reserved.
//
#include <iostream>
#include <string>
#include "switch.h"
int main(int argc, const char * argv[])
{
std::string username = "guest";
bool passwordIsValid = true;
Switch( username, passwordIsValid )
.Case( "admin", true,
[]()
{
std::cout << "Welcome chief" << std::endl;
} )
.Case( "guest", std::ignore,
[&passwordIsValid]()
{
std::cout << "Welcome guest, your password is " << (passwordIsValid ? "valid" : "invalid" ) << std::endl;
} )
.Default( [&username]()
{
std::cout << username << ", you're at the wrong place!" << std::endl;
} );
return 0;
}