22 #ifndef GEARS_UTILITY_MAYBE_TRAITS_HPP
23 #define GEARS_UTILITY_MAYBE_TRAITS_HPP
25 #include "../../meta/alias.hpp"
31 struct has_overloaded_address_of_impl {
33 static auto test(
int) -> decltype(std::declval<T&>().
operator&(), std::true_type{}) {}
35 static std::false_type test(...);
39 struct has_overloaded_address_of : decltype(has_overloaded_address_of_impl::test<T>(0)) {};
41 template<
typename T, meta::DisableIf<has_overloaded_address_of<T>> = meta::_>
42 constexpr T* address_of(T& t) noexcept {
46 template<
typename T, meta::EnableIf<has_overloaded_address_of<T>> = meta::_>
47 T* address_of(T& t) noexcept {
48 return std::addressof(t);
59 struct is_maybe : std::false_type {};
62 struct is_maybe<maybe<T>> : std::true_type {};
66 #endif // GEARS_UTILITY_MAYBE_TRAITS_HPP