Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement LWG-3860 range_common_reference_t is missing #3480

Merged
merged 2 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,9 @@ namespace ranges {
_EXPORT_STD template <range _Rng>
using range_rvalue_reference_t = iter_rvalue_reference_t<iterator_t<_Rng>>;

_EXPORT_STD template <range _Rng>
using range_common_reference_t = iter_common_reference_t<iterator_t<_Rng>>;

#if _HAS_CXX23
_EXPORT_STD template <class _Rng>
concept constant_range = input_range<_Rng> && _Constant_iterator<iterator_t<_Rng>>;
Expand Down
6 changes: 6 additions & 0 deletions tests/std/tests/P0896R4_ranges_range_machinery/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ constexpr bool test_input_range() {
STATIC_ASSERT(std::same_as<ranges::range_rvalue_reference_t<Range&>, RvalueReference>);
STATIC_ASSERT(std::same_as<ranges::range_rvalue_reference_t<Range&&>, RvalueReference>);

// LWG-3860, validate ranges::range_common_reference_t
using CommonReference = std::iter_common_reference_t<Iterator>;
STATIC_ASSERT(std::same_as<ranges::range_common_reference_t<Range>, CommonReference>);
STATIC_ASSERT(std::same_as<ranges::range_common_reference_t<Range&>, CommonReference>);
STATIC_ASSERT(std::same_as<ranges::range_common_reference_t<Range&&>, CommonReference>);

return true;
}

Expand Down