From 7fe47a9d5b1727a61dc724523b530762f6d6ba19 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Thu, 30 Jun 2022 21:38:53 -0700 Subject: Restructure project --- app/source/Cplt/Utils/Variant.hpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 app/source/Cplt/Utils/Variant.hpp (limited to 'app/source/Cplt/Utils/Variant.hpp') diff --git a/app/source/Cplt/Utils/Variant.hpp b/app/source/Cplt/Utils/Variant.hpp new file mode 100644 index 0000000..df2f882 --- /dev/null +++ b/app/source/Cplt/Utils/Variant.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include +#include + +template +struct Overloaded : Ts... +{ + using Ts::operator()...; +}; +template +Overloaded(Ts...) -> Overloaded; + +template +struct VariantCastProxy +{ + std::variant v; + + template + operator std::variant() const + { + return std::visit( + [](auto&& arg) -> std::variant { return arg; }, + v); + } +}; + +/// Use snake_case naming to align with `static_cast`, `dynamic_cast`, etc.. +template +auto variant_cast(std::variant v) -> VariantCastProxy +{ + return { std::move(v) }; +} -- cgit v1.2.3-70-g09d2