ClientServerProject/switch_expression.h

21 lines
395 B
C
Raw Normal View History

2021-02-09 23:02:05 -05:00
#pragma once
#include <functional>
template<typename T>
void on(T what, std::tuple<T, std::function<void()>> match)
{
auto [a,b] = match;
if (what == a)
b;
}
template<typename T>
void on(T what, std::tuple<T, std::function<void()>> match, std::tuple<T, std::function<void()>> others)
{
auto [a,b] = match;
if (what == a)
b;
else
on(what, others);
}