C++ Logo


Advanced search

Subject: Re: container constructors for containers
From: Lyberta (lyberta_at_[hidden])
Date: 2019-09-06 12:05:00

Eduard Antonyan via Std-Discussion:
> Every single time I've used the InputIterator constructors of various
> containers (e.g. vector or set), it's been to convert an existing container
> from one type to another (e.g. set to a vector). As such my code could've
> been simpler and more concise if the constructors simply took a container
> as an argument and did the begin/end internally.
> Any reasons to not have such constructors? These are trivial to write and
> I'm happy to provide the code, but perhaps I'm missing something.
> Thanks.

Yes, every function that takes a pair of iterators should have an
overload that takes std::ranges::input_range (or similar). This should
be easy to add in C++23.

STD-DISCUSSION list run by herb.sutter at gmail.com

Older Archives on Google Groups