Skip to content

Instantly share code, notes, and snippets.

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