Skip to content

Commit

Permalink
core: fix ranges::to for rvalue ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
xlauko committed Jan 8, 2025
1 parent 7946f97 commit 6e21066
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions core/include/gap/core/ranges.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,9 @@ namespace gap::ranges
template< typename container_t, std::ranges::input_range R >
void move_or_copy_elements(R&& rng, container_t& container) {
if constexpr (std::is_rvalue_reference_v< decltype(rng) >) {
std::move(std::ranges::begin(rng), std::ranges::end(rng),
std::back_inserter(container)
);
std::ranges::move(rng, std::back_inserter(container));

Check failure on line 52 in core/include/gap/core/ranges.hpp

View workflow job for this annotation

GitHub Actions / build

‘move’ is not a member of ‘std::ranges’; did you mean ‘std::move’?

Check failure on line 52 in core/include/gap/core/ranges.hpp

View workflow job for this annotation

GitHub Actions / build

‘move’ is not a member of ‘std::ranges’; did you mean ‘std::move’?
} else {
std::copy(std::ranges::begin(rng), std::ranges::end(rng),
std::back_inserter(container)
);
std::ranges::copy(rng, std::back_inserter(container));

Check failure on line 54 in core/include/gap/core/ranges.hpp

View workflow job for this annotation

GitHub Actions / build

‘copy’ is not a member of ‘std::ranges’; did you mean ‘std::copy’?

Check failure on line 54 in core/include/gap/core/ranges.hpp

View workflow job for this annotation

GitHub Actions / build

‘copy’ is not a member of ‘std::ranges’; did you mean ‘std::copy’?
}
}

Expand All @@ -69,7 +65,7 @@ namespace gap::ranges
result_container_t container;

if constexpr (has_reserve< result_container_t >) {
if constexpr (requires { std::ranges::size(range); }) {
if constexpr (std::ranges::sized_range<R>) {
container.reserve(std::ranges::size(range));
}
}
Expand Down

0 comments on commit 6e21066

Please sign in to comment.