[libcxx] r221398 - Fix rvalue bug in __has_operator_addressof

Eric Fiselier eric at efcs.ca
Wed Nov 5 13:20:10 PST 2014


Author: ericwf
Date: Wed Nov  5 15:20:10 2014
New Revision: 221398

URL: http://llvm.org/viewvc/llvm-project?rev=221398&view=rev
Log:
Fix rvalue bug in  __has_operator_addressof

Modified:
    libcxx/trunk/include/type_traits
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp

Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=221398&r1=221397&r2=221398&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Wed Nov  5 15:20:10 2014
@@ -3644,25 +3644,25 @@ struct underlying_type
 template <class _Tp>
 struct __has_operator_addressof_member_imp
 {
-    template <class>
-        static auto __test(__any) -> false_type;
     template <class _Up>
-        static auto __test(_Up* __u)
-            -> typename __select_2nd<decltype(__u->operator&()), true_type>::type;
+        static auto __test(int)
+            -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
+    template <class>
+        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 <class _Tp>
 struct __has_operator_addressof_free_imp
 {
-    template <class>
-        static auto __test(__any) -> false_type;
     template <class _Up>
-        static auto __test(_Up* __u)
-            -> typename __select_2nd<decltype(operator&(*__u)), true_type>::type;
+        static auto __test(int)
+            -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
+    template <class>
+        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 <class _Tp>

Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp?rev=221398&r1=221397&r2=221398&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp Wed Nov  5 15:20:10 2014
@@ -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<B>::value == true, "");
     static_assert(std::__has_operator_addressof<E>::value == true, "");
     static_assert(std::__has_operator_addressof<F>::value == true, "");
+    static_assert(std::__has_operator_addressof<G>::value == true, "");
+    static_assert(std::__has_operator_addressof<H>::value == true, "");
+    static_assert(std::__has_operator_addressof<J>::value == true, "");
 #endif  // _LIBCPP_HAS_NO_CONSTEXPR
 }





More information about the cfe-commits mailing list