Skip to content

Instantly share code, notes, and snippets.

@Garciat
Created July 13, 2017 22:24
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
#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