summaryrefslogtreecommitdiffstats
path: root/src/Globals.h
diff options
context:
space:
mode:
author12xx12 <44411062+12xx12@users.noreply.github.com>2021-02-05 03:05:14 +0100
committerTiger Wang <ziwei.tiger@outlook.com>2021-02-08 13:41:30 +0100
commit2481190d9c9f25fac2f97708c752990f873f44f0 (patch)
tree0b50f6cde0e1bd34b54ab11a933b678c30d30999 /src/Globals.h
parentExplodinator performance optimisations (diff)
downloadcuberite-2481190d9c9f25fac2f97708c752990f873f44f0.tar
cuberite-2481190d9c9f25fac2f97708c752990f873f44f0.tar.gz
cuberite-2481190d9c9f25fac2f97708c752990f873f44f0.tar.bz2
cuberite-2481190d9c9f25fac2f97708c752990f873f44f0.tar.lz
cuberite-2481190d9c9f25fac2f97708c752990f873f44f0.tar.xz
cuberite-2481190d9c9f25fac2f97708c752990f873f44f0.tar.zst
cuberite-2481190d9c9f25fac2f97708c752990f873f44f0.zip
Diffstat (limited to 'src/Globals.h')
-rw-r--r--src/Globals.h20
1 files changed, 20 insertions, 0 deletions
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<class... Ts> struct OverloadedVariantAccess : Ts... { using Ts::operator()...; };
+template<class... Ts> OverloadedVariantAccess(Ts...)->OverloadedVariantAccess<Ts...>;
+
+
+
+
+
/** Clamp X to the specified range. */
template <typename T>
T Clamp(T a_Value, T a_Min, T a_Max)