Date: Sat, 20 Mar 2021 18:48:33 +0100 From: Dimitry Andric <dim@FreeBSD.org> To: Alan Somers <asomers@FreeBSD.org> Cc: Willem Jan Withagen <wjw@digiware.nl>, FreeBSD Hackers <freebsd-hackers@freebsd.org>, FreeBSD Toolchain <freebsd-toolchain@freebsd.org> Subject: Re: Looking for std::map::erase_if Message-ID: <9125B9BA-5B64-46AD-AB61-032889B0BE82@FreeBSD.org> In-Reply-To: <CAOtMX2gxR%2BEjUK%2BurZFP%2BTP6p=W4rPsk37U0oHGmassqxW930g@mail.gmail.com> References: <941ef2dc-e6e1-bd30-0533-f6789b1463b5@digiware.nl> <CAOtMX2g4E3VUQkBe=mBOejpnkDAd2yMn9SChw=5ReMx4Aoe9Fw@mail.gmail.com> <499f895c-d614-86bd-2371-a6dd3ac349d7@digiware.nl> <CAOtMX2gxR%2BEjUK%2BurZFP%2BTP6p=W4rPsk37U0oHGmassqxW930g@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Well, -std=c++20 even, it is that new. :)
That said, it's always hazardous to rely on experimental features, they are effectively unsupported.
As shown on e.g. cppreference.com, you can use an equivalent function that looks like:
auto old_size = c.size();
for (auto i = c.begin(), last = c.end(); i != last; ) {
if (pred(*i)) {
i = c.erase(i);
} else {
++i;
}
}
-Dimitry
> On 20 Mar 2021, at 16:22, Alan Somers <asomers@FreeBSD.org> wrote:
>
> I'm just guessing, but I think you should remove the "experimental" and
> build with -std=c++17 .
> -Alan
>
> On Sat, Mar 20, 2021 at 9:06 AM Willem Jan Withagen <wjw@digiware.nl> wrote:
>
>> On 20-3-2021 15:46, Alan Somers wrote:
>>
>> It looks like it's in there. What code are you trying that doesn't work?
>>
>> Hi Alan,
>>
>> I thought so too, but all tries last 2 weeks did not result into anything
>> that got it compiling...
>> But could be that I did not try hard enough, real work is pulling a lot
>> atm.
>>
>> Code is at:
>>
>> https://github.com/dillaman/ceph/blob/138d71fb0635682510cadda8e4ad5aaab3f39e44/src/librbd/api/Trash.cc#L299
>>
>> Thanx,
>> --WjW
>>
>>
>>> grep erase_if /usr/include/c++/v1/map
>> void erase_if(map<Key, T, Compare, Allocator>& c, Predicate pred); //
>> C++20
>> void erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred);
>> // C++20
>> void erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred)
>> { __libcpp_erase_if_container(__c, __pred); }
>> void erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate
>> __pred)
>> { __libcpp_erase_if_container(__c, __pred); }
>>
>> On Sat, Mar 20, 2021 at 8:39 AM Willem Jan Withagen via freebsd-hackers <
>> freebsd-hackers@freebsd.org> wrote:
>>
>>> Hi,
>>>
>>> [ Trying this on FBSD 12.2 ]
>>>
>>> In the Ceph code new code uses std::map::erase_if.
>>> Which is in Linux imported from <experimental/map>
>>>
>>> Anybody suggestions on libraries to get something matching??
>>>
>>> Thanx,
>>> --WjW
>>> _______________________________________________
>>> freebsd-hackers@freebsd.org mailing list
>>> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
>>> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org
>>> "
>>>
>>
>>
> _______________________________________________
> freebsd-toolchain@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
> To unsubscribe, send any mail to "freebsd-toolchain-unsubscribe@freebsd.org"
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.2
iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCYFY1cgAKCRCwXqMKLiCW
o0K7AKDRg+ynTANYSuoru0z7AvijhLXzXwCgujVObtyYtPaUyg19GqkSVCRlFhI=
=ijzk
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9125B9BA-5B64-46AD-AB61-032889B0BE82>
