File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
loader/include/Geode/utils Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -63,4 +63,23 @@ namespace geode::cast {
6363 }
6464 return nullptr ;
6565 }
66+ /* *
67+ * Repeatedly apply static_cast in order.
68+ * Useful for casting an object to a modify class, which would
69+ * otherwise require multiple casts.
70+ */
71+ template <typename Next, typename ... Chain, typename Original>
72+ static constexpr decltype (auto ) chain_cast(Original&& original) {
73+ if constexpr (sizeof ...(Chain) == 0 ) {
74+ return static_cast <Next>(std::forward<Original>(original));
75+ } else {
76+ return chain_cast<Chain...>(static_cast <Next>(std::forward<Original>(original)));
77+ }
78+ }
79+
80+ template <typename Original>
81+ static constexpr decltype (auto ) chain_cast(Original&& original) {
82+ return std::forward<Original>(original);
83+ }
84+
6685}
You can’t perform that action at this time.
0 commit comments