12 lines
250 B
C++
12 lines
250 B
C++
|
#include <variant>
|
||
|
|
||
|
template<class... Ts>
|
||
|
struct overloaded : Ts...
|
||
|
{
|
||
|
using Ts::operator()...;
|
||
|
};
|
||
|
|
||
|
template<class T, class... Ts>
|
||
|
auto match(const T& event, Ts&&... args){
|
||
|
return std::visit(overloaded{std::forward<Ts>(args)...}, event);
|
||
|
}
|