Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libcxx][ranges] Implement
ranges::borrowed_range
.
Differential Revision: https://reviews.llvm.org/D102426
- Loading branch information
Showing
23 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
libcxx/test/std/ranges/range.range/borrowed_range.compile.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// UNSUPPORTED: c++03, c++11, c++14, c++17 | ||
// UNSUPPORTED: libcpp-no-concepts | ||
// UNSUPPORTED: gcc-10 | ||
|
||
// template<class T> | ||
// concept borrowed_range; | ||
|
||
#include <ranges> | ||
|
||
struct NotRange { | ||
int begin() const; | ||
int end() const; | ||
}; | ||
|
||
struct Range { | ||
int *begin(); | ||
int *end(); | ||
}; | ||
|
||
struct ConstRange { | ||
int *begin() const; | ||
int *end() const; | ||
}; | ||
|
||
struct BorrowedRange { | ||
int *begin() const; | ||
int *end() const; | ||
}; | ||
|
||
template<> | ||
inline constexpr bool std::ranges::enable_borrowed_range<BorrowedRange> = true; | ||
|
||
static_assert(!std::ranges::borrowed_range<NotRange>); | ||
static_assert(!std::ranges::borrowed_range<NotRange&>); | ||
static_assert(!std::ranges::borrowed_range<const NotRange>); | ||
static_assert(!std::ranges::borrowed_range<const NotRange&>); | ||
static_assert(!std::ranges::borrowed_range<NotRange&&>); | ||
|
||
static_assert(!std::ranges::borrowed_range<Range>); | ||
static_assert( std::ranges::borrowed_range<Range&>); | ||
static_assert(!std::ranges::borrowed_range<const Range>); | ||
static_assert(!std::ranges::borrowed_range<const Range&>); | ||
static_assert(!std::ranges::borrowed_range<Range&&>); | ||
|
||
static_assert(!std::ranges::borrowed_range<ConstRange>); | ||
static_assert( std::ranges::borrowed_range<ConstRange&>); | ||
static_assert(!std::ranges::borrowed_range<const ConstRange>); | ||
static_assert( std::ranges::borrowed_range<const ConstRange&>); | ||
static_assert(!std::ranges::borrowed_range<ConstRange&&>); | ||
|
||
static_assert( std::ranges::borrowed_range<BorrowedRange>); | ||
static_assert( std::ranges::borrowed_range<BorrowedRange&>); | ||
static_assert( std::ranges::borrowed_range<const BorrowedRange>); | ||
static_assert( std::ranges::borrowed_range<const BorrowedRange&>); | ||
static_assert( std::ranges::borrowed_range<BorrowedRange&&>); |
28 changes: 28 additions & 0 deletions
28
libcxx/test/std/ranges/range.range/borrowed_range.subsumption.compile.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// UNSUPPORTED: c++03, c++11, c++14, c++17 | ||
// UNSUPPORTED: libcpp-no-concepts | ||
// UNSUPPORTED: gcc-10 | ||
|
||
// template<class T> | ||
// concept borrowed_range; | ||
|
||
#include <ranges> | ||
|
||
template <std::ranges::range R> | ||
consteval bool check_subsumption() { | ||
return false; | ||
} | ||
|
||
template <std::ranges::borrowed_range R> | ||
consteval bool check_subsumption() { | ||
return true; | ||
} | ||
|
||
static_assert(check_subsumption<int (&)[8]>()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters