Skip to content

Francisco/using iterators for containers#2470

Merged
lemire merged 3 commits intomasterfrom
francisco/using_iterators_for_containers
Sep 25, 2025
Merged

Francisco/using iterators for containers#2470
lemire merged 3 commits intomasterfrom
francisco/using_iterators_for_containers

Conversation

@FranciscoThiesen
Copy link
Member

Implemented Matt Godbolt's suggestion of using iterators on the concept that matches generic containers. It is broader then depending on the subscript operator + size, so we gain std::list for free... (and a few other containers)

#2459

@lemire
Copy link
Member

lemire commented Sep 25, 2025

cc @mattgodbolt

@lemire
Copy link
Member

lemire commented Sep 25, 2025

Following @the-moisrex's comment, @FranciscoThiesen, could we go with...

template <typename T>
concept container_but_not_string =
std::ranges::input_range<T> && !std::is_same_v<T, std::string> &&
    !std::is_same_v<T, std::string_view> && !std::is_same_v<T, const char *>;

Copy link
Member

@lemire lemire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is clearly better code. :-)

@lemire
Copy link
Member

lemire commented Sep 25, 2025

We shall merge when the tests go green.

@lemire
Copy link
Member

lemire commented Sep 25, 2025

This will be in the next release.

@lemire lemire merged commit 4456a10 into master Sep 25, 2025
156 checks passed
@lemire lemire deleted the francisco/using_iterators_for_containers branch September 25, 2025 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants