This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
template <typename T> | |
struct wrap; | |
template <typename T> | |
constexpr auto is_wrap_v = false; | |
template <typename T> | |
constexpr auto is_wrap_v<wrap<T>> = true; | |
template <typename T> | |
struct wrap { | |
auto operator->() { | |
if constexpr (is_wrap_v<T>) { | |
return value.operator->(); | |
} else { | |
return &value; | |
} | |
} | |
T value; | |
}; | |
struct vec2 { | |
float x, y; | |
}; | |
auto hello(wrap<wrap<wrap<vec2>>> w) { | |
return w->x + w->y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment