Skip to content

Instantly share code, notes, and snippets.

@kikairoya
Last active December 17, 2015 01:38
Show Gist options
  • Save kikairoya/5529538 to your computer and use it in GitHub Desktop.
Save kikairoya/5529538 to your computer and use it in GitHub Desktop.
#include <type_traits>
namespace detail {
template <typename T>
struct identity { typedef T type; };
template <typename T>
struct has_overloaded_address_operator_impl {
template <typename U>
static std::true_type check(U *p, identity<decltype(p->operator &())> * = 0);
template <typename U>
static std::true_type check(U *p, identity<decltype(operator &(*p))> * = 0);
static std::false_type check(const volatile void *);
typedef decltype(check((T *)0)) type;
};
}
template <typename T>
struct has_overloaded_address_operator: detail::has_overloaded_address_operator_impl<T>::type { };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment