[libcxx-commits] [PATCH] D74287: [libcxx] Fix unintended ADL inside ref(reference_wrapper<T>) and cref(reference_wrapper<T>)
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 20 09:25:00 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe442f38395f7: [libc++] Fix unintended ADL inside ref(reference_wrapper<T>) and cref… (authored by logan-5, committed by ldionne).
Changed prior to commit:
https://reviews.llvm.org/D74287?vs=243399&id=245675#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74287/new/
https://reviews.llvm.org/D74287
Files:
libcxx/include/__functional_base
libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp
libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
Index: libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
===================================================================
--- libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
+++ libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
@@ -24,6 +24,11 @@
template <typename T>
bool call_pred ( T pred ) { return pred(5); }
+namespace adl {
+ struct A {};
+ void ref(A) {}
+}
+
int main(int, char**)
{
{
@@ -33,6 +38,13 @@
assert(&r2.get() == &i);
}
{
+ adl::A a;
+ std::reference_wrapper<adl::A> a1 = std::ref(a);
+ std::reference_wrapper<adl::A> a2 = std::ref(a1);
+ assert(&a2.get() == &a);
+ }
+
+ {
unary_counting_predicate<bool(*)(int), int> cp(is5);
assert(!cp(6));
assert(cp.count() == 1);
Index: libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp
===================================================================
--- libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp
+++ 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<const int> r2 = std::cref(r1);
assert(&r2.get() == &i);
+ {
+ adl::A a;
+ std::reference_wrapper<const adl::A> a1 = std::cref(a);
+ std::reference_wrapper<const adl::A> a2 = std::cref(a1);
+ assert(&a2.get() == &a);
+ }
+
return 0;
}
Index: libcxx/include/__functional_base
===================================================================
--- libcxx/include/__functional_base
+++ 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 <class _Tp>
@@ -538,7 +538,7 @@
reference_wrapper<const _Tp>
cref(reference_wrapper<_Tp> __t) _NOEXCEPT
{
- return cref(__t.get());
+ return _VSTD::cref(__t.get());
}
#ifndef _LIBCPP_CXX03_LANG
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74287.245675.patch
Type: text/x-patch
Size: 2204 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200220/a8158da8/attachment-0001.bin>
More information about the libcxx-commits
mailing list