Skip to content
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
4 changes: 2 additions & 2 deletions stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,7 @@ namespace ranges {
if constexpr (random_access_range<_Vw>) {
return _RANGES begin(_Range);
} else {
const auto _Size = size();
const auto _Size = static_cast<range_difference_t<_Vw>>(size());
return counted_iterator{_RANGES begin(_Range), _Size};
}
} else {
Expand All @@ -1940,7 +1940,7 @@ namespace ranges {
if constexpr (random_access_range<const _Vw>) {
return _RANGES begin(_Range);
} else {
const auto _Size = size();
const auto _Size = static_cast<range_difference_t<_Vw>>(size());
return counted_iterator{_RANGES begin(_Range), _Size};
}
} else {
Expand Down
10 changes: 10 additions & 0 deletions tests/std/tests/P0896R4_views_take/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <algorithm>
#include <cassert>
#include <forward_list>
#include <map>
#include <ranges>
#include <span>
#include <string_view>
Expand Down Expand Up @@ -510,6 +511,13 @@ constexpr void output_range_test() {
}
}

void test_DevCom_1397309() {
constexpr int expected[] = {4, 8};
const map<int, string_view> values{{4, "Hello"sv}, {8, "Beautiful"sv}, {10, "World"sv}};

assert(ranges::equal(values | ranges::views::take(2) | ranges::views::keys, expected));
}

int main() {
// Validate views
{ // ... copyable
Expand Down Expand Up @@ -558,4 +566,6 @@ int main() {

STATIC_ASSERT((instantiation_test(), true));
instantiation_test();

test_DevCom_1397309();
}