aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/Util.h
diff options
context:
space:
mode:
authorGiacomo Pozzoni <giacomopoz@gmail.com>2020-04-09 09:59:10 +0000
committerShauren <shauren.trinity@gmail.com>2022-01-01 13:06:27 +0100
commita947ee191276578d9bfa23e2f678574e5f5fa5a0 (patch)
tree961773e54e1f73e33af238ac502d88d77234678d /src/common/Utilities/Util.h
parentc0c867e6e50ca19efafcd09ef858cf86723e7ea4 (diff)
Core/SAI: Allow SMART_TARGET_ACTION_INVOKER to target GameObjects (#24416)
* Core/SAI: Allow SMART_TARGET_ACTION_INVOKER to target GameObjects * Include new Coalesce(..) template by @Shauren (cherry picked from commit 90b00288c24dfefccb338bd33b025cf85e82076d)
Diffstat (limited to 'src/common/Utilities/Util.h')
-rw-r--r--src/common/Utilities/Util.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h
index a68c4d0fc66..c61036d13ef 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -580,6 +580,18 @@ constexpr typename std::underlying_type<E>::type AsUnderlyingType(E enumValue)
return static_cast<typename std::underlying_type<E>::type>(enumValue);
}
+template<typename Ret, typename Only>
+Ret* Coalesce(Only* arg)
+{
+ return arg;
+}
+
+template<typename Ret, typename T1, typename... T>
+Ret* Coalesce(T1* first, T*... rest)
+{
+ return static_cast<Ret*>(first ? static_cast<Ret*>(first) : Coalesce<Ret>(rest...));
+}
+
template<typename T>
struct NonDefaultConstructible
{