From 2481190d9c9f25fac2f97708c752990f873f44f0 Mon Sep 17 00:00:00 2001 From: 12xx12 <44411062+12xx12@users.noreply.github.com> Date: Fri, 5 Feb 2021 02:05:14 +0000 Subject: CompositeChat: use variants --- src/Globals.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/Globals.h') diff --git a/src/Globals.h b/src/Globals.h index 7b488326f..bb512d89d 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -317,6 +317,26 @@ namespace cpp20 +/** +You can use this struct to use in std::visit +example: +std::visit( + OverloadedVariantAccess + { + [&] (cFirstType & a_FirstTypeObject) { // Your code to handle cFirstType }, + [&] (cSecondType & a_SecondTypeObject) { // YourCode to handle cSecondType }, + ... + } +, YourVariant); +You can use constant references if you want to. +*/ +template struct OverloadedVariantAccess : Ts... { using Ts::operator()...; }; +template OverloadedVariantAccess(Ts...)->OverloadedVariantAccess; + + + + + /** Clamp X to the specified range. */ template T Clamp(T a_Value, T a_Min, T a_Max) -- cgit v1.2.3