Skip to content

Commit

Permalink
Implement LWG-3860 range_common_reference_t is missing (#3480)
Browse files Browse the repository at this point in the history
Co-authored-by: Jakub Mazurkiewicz <[email protected]>
  • Loading branch information
fsb4000 and JMazurkiewicz authored Feb 23, 2023
1 parent 1bddf4c commit 7aaa151
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,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

0 comments on commit 7aaa151

Please sign in to comment.