diff --git a/libcxx/include/__functional_base b/libcxx/include/__functional_base --- a/libcxx/include/__functional_base +++ b/libcxx/include/__functional_base @@ -522,7 +522,7 @@ reference_wrapper<_Tp> ref(reference_wrapper<_Tp> __t) _NOEXCEPT { - return ref(__t.get()); + return _VSTD::ref(__t.get()); } template @@ -538,7 +538,7 @@ 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 --- 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 @@ 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 --- 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 @@ template bool call_pred ( T pred ) { return pred(5); } +namespace adl { + struct A {}; + void ref(A) {} +} + int main(int, char**) { { @@ -32,6 +37,13 @@ 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));