C++ Logo

std-proposals

Advanced search

Re: Finding the index of an element (std::find_first_index)

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Sat, 3 Oct 2020 12:51:49 +0200
Il 03/10/20 11:42, Simon Kraemer via Std-Proposals ha scritto:
> > auto i = /* insert std_find_if + distance or the proposed template to
> search in bigDynamicList. */
> > someLUT[i] = 42;
>
> Why not just use iterators as they are meant to be used?
>
> auto iter = std::find(...);
> *iter = 42;
>
> Same number of lines, no duplicate lookup.

The example uses two different containers. You find the index in one
container, and use it to index in the second. How do you use iterators
to do the same?

Thanks,

-- 
Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

Received on 2020-10-03 05:51:58