diff --git a/libcxx/include/__functional_base b/libcxx/include/__functional_base index ca761c409b627b..f591bf5a9dceef 100644 --- a/libcxx/include/__functional_base +++ b/libcxx/include/__functional_base @@ -522,7 +522,7 @@ inline _LIBCPP_INLINE_VISIBILITY reference_wrapper<_Tp> ref(reference_wrapper<_Tp> __t) _NOEXCEPT { - return ref(__t.get()); + return _VSTD::ref(__t.get()); } template @@ -538,7 +538,7 @@ inline _LIBCPP_INLINE_VISIBILITY reference_wrapper cref(reference_wrapper<_Tp> __t) _NOEXCEPT { - return cref(__t.get()); + return _VSTD::cref(__t.get()); } #ifndef _LIBCPP_CXX03_LANG diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp index b4707f4e4bc30a..d76bcf9245c09f 100644 --- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp @@ -17,6 +17,11 @@ #include "test_macros.h" +namespace adl { + struct A {}; + void cref(A) {} +} + int main(int, char**) { const int i = 0; @@ -24,5 +29,12 @@ int main(int, char**) std::reference_wrapper r2 = std::cref(r1); assert(&r2.get() == &i); + { + adl::A a; + std::reference_wrapper a1 = std::cref(a); + std::reference_wrapper a2 = std::cref(a1); + assert(&a2.get() == &a); + } + return 0; } diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp index 8761357eb82f87..9ab62a20a87310 100644 --- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp @@ -24,6 +24,11 @@ bool is5 ( int i ) { return i == 5; } template bool call_pred ( T pred ) { return pred(5); } +namespace adl { + struct A {}; + void ref(A) {} +} + int main(int, char**) { { @@ -32,6 +37,13 @@ int main(int, char**) std::reference_wrapper r2 = std::ref(r1); assert(&r2.get() == &i); } + { + adl::A a; + std::reference_wrapper a1 = std::ref(a); + std::reference_wrapper a2 = std::ref(a1); + assert(&a2.get() == &a); + } + { unary_counting_predicate cp(is5); assert(!cp(6));