Re: C++17 polymorphic allocator support in libstdc++

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 20 Jan 2022, 03:55 Itaru Kitayama via Gcc-help, <
gcc-help@xxxxxxxxxxx> 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

>



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux