[libcxx-commits] [libcxx] 9be193b - [libc++] [ranges] Finish ADL-proofing ranges::data.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jan 12 15:18:25 PST 2022
Author: Arthur O'Dwyer
Date: 2022-01-12T18:16:22-05:00
New Revision: 9be193bc58b356e2d2e0bddff59a404358e2c75e
URL: https://github.com/llvm/llvm-project/commit/9be193bc58b356e2d2e0bddff59a404358e2c75e
DIFF: https://github.com/llvm/llvm-project/commit/9be193bc58b356e2d2e0bddff59a404358e2c75e.diff
LOG: [libc++] [ranges] Finish ADL-proofing ranges::data.
This should have been part of D116239.
Added:
Modified:
libcxx/include/__ranges/data.h
libcxx/test/std/ranges/range.access/begin.pass.cpp
libcxx/test/std/ranges/range.access/data.pass.cpp
libcxx/test/std/ranges/range.access/empty.pass.cpp
libcxx/test/std/ranges/range.access/end.pass.cpp
libcxx/test/std/ranges/range.access/size.pass.cpp
libcxx/test/std/ranges/range.access/ssize.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/include/__ranges/data.h b/libcxx/include/__ranges/data.h
index de39312b49cd..20d84912d278 100644
--- a/libcxx/include/__ranges/data.h
+++ b/libcxx/include/__ranges/data.h
@@ -9,6 +9,7 @@
#ifndef _LIBCPP___RANGES_DATA_H
#define _LIBCPP___RANGES_DATA_H
+#include <__concepts/class_or_enum.h>
#include <__config>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
@@ -35,6 +36,7 @@ namespace __data {
template <class _Tp>
concept __member_data =
__can_borrow<_Tp> &&
+ __workaround_52970<_Tp> &&
requires(_Tp&& __t) {
{ _LIBCPP_AUTO_CAST(__t.data()) } -> __ptr_to_object;
};
diff --git a/libcxx/test/std/ranges/range.access/begin.pass.cpp b/libcxx/test/std/ranges/range.access/begin.pass.cpp
index 36741f16823e..07b1a3b89a7f 100644
--- a/libcxx/test/std/ranges/range.access/begin.pass.cpp
+++ b/libcxx/test/std/ranges/range.access/begin.pass.cpp
@@ -307,7 +307,9 @@ static_assert(noexcept(std::ranges::cbegin(brar)));
struct Incomplete;
template<class T> struct Holder { T t; };
static_assert(!std::is_invocable_v<RangeBeginT, Holder<Incomplete>*>);
+static_assert(!std::is_invocable_v<RangeBeginT, Holder<Incomplete>*&>);
static_assert(!std::is_invocable_v<RangeCBeginT, Holder<Incomplete>*>);
+static_assert(!std::is_invocable_v<RangeCBeginT, Holder<Incomplete>*&>);
int main(int, char**) {
static_assert(testReturnTypes());
diff --git a/libcxx/test/std/ranges/range.access/data.pass.cpp b/libcxx/test/std/ranges/range.access/data.pass.cpp
index da4d79d724f3..8f2446287a30 100644
--- a/libcxx/test/std/ranges/range.access/data.pass.cpp
+++ b/libcxx/test/std/ranges/range.access/data.pass.cpp
@@ -210,12 +210,14 @@ constexpr bool testViaRangesBegin() {
struct Incomplete;
template<class T> struct Holder { T t; };
static_assert(!std::is_invocable_v<RangeDataT, Holder<Incomplete>*>);
+static_assert(!std::is_invocable_v<RangeDataT, Holder<Incomplete>*&>);
struct RandomButNotContiguous {
random_access_iterator<int*> begin() const;
random_access_iterator<int*> end() const;
};
static_assert(!std::is_invocable_v<RangeDataT, RandomButNotContiguous>);
+static_assert(!std::is_invocable_v<RangeDataT, RandomButNotContiguous&>);
int main(int, char**) {
static_assert(testReturnTypes());
diff --git a/libcxx/test/std/ranges/range.access/empty.pass.cpp b/libcxx/test/std/ranges/range.access/empty.pass.cpp
index 5724acc67dee..dc6a2ac30f2f 100644
--- a/libcxx/test/std/ranges/range.access/empty.pass.cpp
+++ b/libcxx/test/std/ranges/range.access/empty.pass.cpp
@@ -172,6 +172,7 @@ constexpr bool testBeginEqualsEnd() {
struct Incomplete;
template<class T> struct Holder { T t; };
static_assert(!std::is_invocable_v<RangeEmptyT, Holder<Incomplete>*>);
+static_assert(!std::is_invocable_v<RangeEmptyT, Holder<Incomplete>*&>);
int main(int, char**) {
testEmptyMember();
diff --git a/libcxx/test/std/ranges/range.access/end.pass.cpp b/libcxx/test/std/ranges/range.access/end.pass.cpp
index 9d10d0aa4aed..5f4f05279cdd 100644
--- a/libcxx/test/std/ranges/range.access/end.pass.cpp
+++ b/libcxx/test/std/ranges/range.access/end.pass.cpp
@@ -357,7 +357,9 @@ static_assert(noexcept(std::ranges::cend(erar)));
struct Incomplete;
template<class T> struct Holder { T t; };
static_assert(!std::is_invocable_v<RangeEndT, Holder<Incomplete>*>);
+static_assert(!std::is_invocable_v<RangeEndT, Holder<Incomplete>*&>);
static_assert(!std::is_invocable_v<RangeCEndT, Holder<Incomplete>*>);
+static_assert(!std::is_invocable_v<RangeCEndT, Holder<Incomplete>*&>);
int main(int, char**) {
static_assert(testReturnTypes());
diff --git a/libcxx/test/std/ranges/range.access/size.pass.cpp b/libcxx/test/std/ranges/range.access/size.pass.cpp
index 915e67e19475..2cfa2ad37dfb 100644
--- a/libcxx/test/std/ranges/range.access/size.pass.cpp
+++ b/libcxx/test/std/ranges/range.access/size.pass.cpp
@@ -318,6 +318,7 @@ constexpr bool testRanges() {
struct Incomplete;
template<class T> struct Holder { T t; };
static_assert(!std::is_invocable_v<RangeSizeT, Holder<Incomplete>*>);
+static_assert(!std::is_invocable_v<RangeSizeT, Holder<Incomplete>*&>);
int main(int, char**) {
testArrayType();
diff --git a/libcxx/test/std/ranges/range.access/ssize.pass.cpp b/libcxx/test/std/ranges/range.access/ssize.pass.cpp
index c351928c8fe6..f20df6b97020 100644
--- a/libcxx/test/std/ranges/range.access/ssize.pass.cpp
+++ b/libcxx/test/std/ranges/range.access/ssize.pass.cpp
@@ -82,6 +82,7 @@ constexpr bool test() {
struct Incomplete;
template<class T> struct Holder { T t; };
static_assert(!std::is_invocable_v<RangeSSizeT, Holder<Incomplete>*>);
+static_assert(!std::is_invocable_v<RangeSSizeT, Holder<Incomplete>*&>);
int main(int, char**) {
test();
More information about the libcxx-commits
mailing list