Created
July 13, 2017 22:24
-
-
Save Garciat/d63d79976ad9c09aa771915a76281530 to your computer and use it in GitHub Desktop.
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