* C++17 polymorphic allocator support in libstdc++
@ 2022-01-20 3:54 Itaru Kitayama
2022-01-20 8:22 ` Jonathan Wakely
0 siblings, 1 reply; 2+ messages in thread
From: Itaru Kitayama @ 2022-01-20 3:54 UTC (permalink / raw)
To: gcc-help
I am wondering how GCC C++ runtime library addresses this Notes in:
https://en.cppreference.com/w/cpp/memory/polymorphic_allocator
if I use consistently the same polymorphic allocator, be it the
default or custom one, for
the std::pmr::vectors, I don't need to worry about the Notes?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: C++17 polymorphic allocator support in libstdc++
2022-01-20 3:54 C++17 polymorphic allocator support in libstdc++ Itaru Kitayama
@ 2022-01-20 8:22 ` Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2022-01-20 8:22 UTC (permalink / raw)
To: Itaru Kitayama; +Cc: gcc-help
On Thu, 20 Jan 2022, 03:55 Itaru Kitayama via Gcc-help, <
gcc-help@gcc.gnu.org> wrote:
> I am wondering how GCC C++ runtime library addresses this Notes in:
>
> https://en.cppreference.com/w/cpp/memory/polymorphic_allocator
>
> if I use consistently the same polymorphic allocator, be it the
> default or custom one, for
> the std::pmr::vectors, I don't need to worry about the Notes?
>
Correct. But because a polymorphic_allocator doesn't propagate, it's up to
you to ensure you use it consistently. If you construct two pmr::vector
objects with unequal allocators, you must not swap them.
If you compile with -D_GLIBCXX_ASSERTIONS the library will abort the
program if you try to swap containers with unequal allocators:
https://gcc.gnu.org/git?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/include/bits/stl_vector.h;h=8e2fcc6f49b2061265cf71ed1b214e7bb5b87fa0;hb=HEAD#l1568
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-20 8:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20 3:54 C++17 polymorphic allocator support in libstdc++ Itaru Kitayama
2022-01-20 8:22 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).