aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/Util.h
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2017-07-23 23:32:20 +0200
committerShauren <shauren.trinity@gmail.com>2017-07-23 23:32:20 +0200
commitfdd9227b232db9aae9bc4b2c60ca4de2cdaa0b54 (patch)
tree0294448c47056ba3ff7ae84ad55af904c32ada3d /src/common/Utilities/Util.h
parent40a45540afdb22984a9da50b070d45d6be8b045d (diff)
Core/Misc: Util changes
* Move IteratorPair to its own header * Add AsUnderlyingType function to cast enum value to its underlying type (avoids repeating std::underlying_type everywhere)
Diffstat (limited to 'src/common/Utilities/Util.h')
-rw-r--r--src/common/Utilities/Util.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h
index eac0611f913..92e0a37b0a3 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -537,4 +537,11 @@ bool CompareValues(ComparisionType type, T val1, T val2)
}
}
+template<typename E>
+typename std::underlying_type<E>::type AsUnderlyingType(E enumValue)
+{
+ static_assert(std::is_enum<E>::value, "AsUnderlyingType can only be used with enums");
+ return static_cast<typename std::underlying_type<E>::type>(enumValue);
+}
+
#endif