diff --git a/src/util/system.h b/src/util/system.h --- a/src/util/system.h +++ b/src/util/system.h @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -498,6 +499,16 @@ dst.insert(src.begin(), src.end()); } +/** + * Helper function to access the contained object of a std::any instance. + * Returns a pointer to the object if passed instance has a value and the type + * matches, nullptr otherwise. + */ +template T *AnyPtr(const std::any &any) noexcept { + T *const *ptr = std::any_cast(&any); + return ptr ? *ptr : nullptr; +} + #ifdef WIN32 class WinCmdLineArgs { public: