This patch implements C++26 std::polymorphic as specified in P3019 with
amendment to move assignment from LWG 4251.
The implementation always allocate stored object on the heap. The manager
function (_M_manager) is similary keep with the object (polymorphic::_Obj),
which reduces the size of the polymorphic to size of the single pointer plus
allocator (that is declared with [[no_unique_address]]).
The implementation does not not use small-object optimization (SSO). We may
consider adding this in the future, as SSO is allowed by the standard. However,
storing any polimorphic object will require providing space for two pointers
(manager function and vtable pointer) and user-declared data members.
PR libstdc++/119152
libstdc++-v3/ChangeLog:
* include/bits/indirect.h (std::polymorphic, pmr::polymorphic)
[__glibcxx_polymorphic]: Define.
* include/bits/version.def (polymorphic): Define.
* include/bits/version.h: Regenerate.
* include/std/memory: Define __cpp_lib_polymorphic.
* testsuite/std/memory/polymorphic/copy.cc: New test.
* testsuite/std/memory/polymorphic/copy_alloc.cc: New test.
* testsuite/std/memory/polymorphic/ctor.cc: New test.
* testsuite/std/memory/polymorphic/ctor_poly.cc: New test.
* testsuite/std/memory/polymorphic/incomplete.cc: New test.
* testsuite/std/memory/polymorphic/invalid_neg.cc: New test.
* testsuite/std/memory/polymorphic/move.cc: New test.
* testsuite/std/memory/polymorphic/move_alloc.cc: New test.
Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>