Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #119611

Re: std::map::emplace useful in any way?

From Andrey Tarasevich <andreytarasevich@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: std::map::emplace useful in any way?
Date 2024-07-07 09:16 -0700
Organization A noiseless patient Spider
Message-ID <v6ef1f$d8pb$1@dont-email.me> (permalink)
References (4 earlier) <87frsugrt7.fsf@ID-208667.user.individual.de> <v5sjtb$mt9c$1@raubtier-asyl.eternal-september.org> <v5t0ps$ooab$1@dont-email.me> <v5u4l6$12bpj$1@raubtier-asyl.eternal-september.org> <v6dtfq$ah15$1@raubtier-asyl.eternal-september.org>

Show all headers | View raw


On 07/07/24 4:17 AM, Bonita Montero wrote:
> Am 01.07.2024 um 13:41 schrieb Bonita Montero:
>> Am 01.07.2024 um 03:29 schrieb Andrey Tarasevich:
>>> On 06/30/24 2:49 PM, Bonita Montero wrote:
>>>>>
>>>>> What about using lower_bound() and emplace_hint() instead? That is
>>>>> available since C++11.
>>>>
>>>> lower_bound() needs a random-access iterator since it does a binary
>>>> search.
>>>>
>>>
>>> That's actually one of those curious spots in the standard library: 
>>> it doesn't needs a random-access iterator. It needs a forward iterator.
>>
>> Interesting, but the algorithm for MSVC is still binary partitioning.
>> Internally a sth. like find_first_if would make more sense. But I think
>> most developers would be intelligent enough to use find_first_if their-
>> selfes.
>>
> 
> I checked the source and found that the MSVC-code simply uses distance()
> and advance(), and both are specialized for non random-access iterators.

This approach, when random-access is emulated through sequential access 
(seemingly unnecessarily), is present in other places of the library and 
not only in MSVC's implementation

https://stackoverflow.com/questions/40622430/stdlistsort-why-the-sudden-switch-to-top-down-strategy

-- 
Best regards,
Andrey

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

std::map::emplace useful in any way? Marcel Mueller <news.5.maazl@spamgourmet.org> - 2024-05-25 17:57 +0200
  Re: std::map::emplace useful in any way? Paavo Helde <eesnimi@osa.pri.ee> - 2024-05-25 20:37 +0300
    Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-28 17:53 +0200
      Re: std::map::emplace useful in any way? Paavo Helde <eesnimi@osa.pri.ee> - 2024-05-29 11:11 +0300
        Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-29 11:47 +0200
          Re: std::map::emplace useful in any way? Paavo Helde <eesnimi@osa.pri.ee> - 2024-05-29 15:05 +0300
            Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-29 18:56 +0200
              Re: std::map::emplace useful in any way? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-29 12:23 -0700
                Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-30 16:01 +0200
  Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-25 19:41 +0200
    Re: std::map::emplace useful in any way? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-06-30 09:47 -0700
      Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-06-30 19:15 +0200
        Re: std::map::emplace useful in any way? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-06-30 11:46 -0700
        Re: std::map::emplace useful in any way? usenet@stegropa.de (Stefan Große Pawig) - 2024-06-30 21:21 +0200
          Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-06-30 23:49 +0200
            Re: std::map::emplace useful in any way? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-06-30 18:29 -0700
              Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-07-01 13:41 +0200
                Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-07-07 13:17 +0200
                Re: std::map::emplace useful in any way? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-07-07 09:16 -0700
                Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-07-07 18:18 +0200
            Re: std::map::emplace useful in any way? usenet@stegropa.de (Stefan Große Pawig) - 2024-07-01 07:41 +0200
  Re: std::map::emplace useful in any way? Sam <sam@email-scan.com> - 2024-05-25 18:29 -0400
  Re: std::map::emplace useful in any way? usenet@stegropa.de (Stefan Große Pawig) - 2024-06-30 21:09 +0200
  Re: std::map::emplace useful in any way? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-06-30 13:32 -0700
    Re: std::map::emplace useful in any way? Marcel Mueller <news.5.maazl@spamgourmet.org> - 2024-07-07 11:09 +0200

csiph-web