From b6e0ef2deb368009add8edba9e3606b08e32cfe0 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Wed, 5 Nov 2014 21:20:10 +0000 Subject: [PATCH] Fix rvalue bug in __has_operator_addressof git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@221398 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/type_traits | 20 +++++++++---------- .../__has_operator_addressof.pass.cpp | 15 +++++++++++++- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/include/type_traits b/include/type_traits index 7a7b4c1a..90ebfcd2 100644 --- a/include/type_traits +++ b/include/type_traits @@ -3644,25 +3644,25 @@ struct underlying_type template struct __has_operator_addressof_member_imp { - template - static auto __test(__any) -> false_type; template - static auto __test(_Up* __u) - -> typename __select_2ndoperator&()), true_type>::type; + static auto __test(int) + -> typename __select_2nd().operator&()), true_type>::type; + template + static auto __test(long) -> false_type; - static const bool value = decltype(__test<_Tp>(nullptr))::value; + static const bool value = decltype(__test<_Tp>(0))::value; }; template struct __has_operator_addressof_free_imp { - template - static auto __test(__any) -> false_type; template - static auto __test(_Up* __u) - -> typename __select_2nd::type; + static auto __test(int) + -> typename __select_2nd())), true_type>::type; + template + static auto __test(long) -> false_type; - static const bool value = decltype(__test<_Tp>(nullptr))::value; + static const bool value = decltype(__test<_Tp>(0))::value; }; template diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp index 81368939..201f0722 100644 --- a/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp +++ b/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp @@ -41,9 +41,19 @@ struct E }; struct F {}; - constexpr F* operator&(F const &) { return nullptr; } +struct G {}; +constexpr G* operator&(G &&) { return nullptr; } + +struct H {}; +constexpr H* operator&(H const &&) { return nullptr; } + +struct J +{ + constexpr J* operator&() &&; +}; + #endif // _LIBCPP_HAS_NO_CONSTEXPR int main() @@ -54,5 +64,8 @@ int main() static_assert(std::__has_operator_addressof::value == true, ""); static_assert(std::__has_operator_addressof::value == true, ""); static_assert(std::__has_operator_addressof::value == true, ""); + static_assert(std::__has_operator_addressof::value == true, ""); + static_assert(std::__has_operator_addressof::value == true, ""); + static_assert(std::__has_operator_addressof::value == true, ""); #endif // _LIBCPP_HAS_NO_CONSTEXPR }