Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 412 Bytes

File metadata and controls

17 lines (13 loc) · 412 Bytes

C++ multi-switch implementation

Requires C++14, tested with gcc, clang and VS 2015.

#include "switch.h"

std::string username = ...;
bool passwordIsValid = ...;

Switch( username, passwordIsValid )
	.Case( "admin", true,
		[](){ /* admin user with valid password */ } )
	.Case( "guest", std::ignore,
		[](){ /* guest user, valid or invalid password */ } )
	.Default( [](){ /* default case */ } );