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
committerTreeston <treeston.mmoc@gmail.com>2017-07-29 15:04:45 +0200
commitd24ce1739a799042d5a164794c09674227c8572c (patch)
tree22a4985cf3be88b2ea3d728dd12c7492b3f4f65e /src/common/Utilities/Util.h
parent9cbacb56da20b4242d6acd65c4a1babfec4e8158 (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) (cherry picked from commit fdd9227b232db9aae9bc4b2c60ca4de2cdaa0b54)
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 458c783152c..ec3f5c2c9e2 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -493,4 +493,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