From 6dcac0cf8439f8ea8e1e1df740060a9f7c9d8c42 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Tue, 18 Aug 2026 11:57:47 +0200 Subject: [PATCH] Document that polymorphic archives require an nvp Which archive a polymorphic one stands for is settled at run time, so a value written through it has to carry a name in case that archive turns out to be an XML one, where values are elements. A templated XML archive rejects an unnamed value where it is written, but the polymorphic interface cannot: at that point it does not yet know what it is writing to. In the absence of a name, the value goes out with no element around it and the document will not read back. Reported in #189. --- doc/archive_reference.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/archive_reference.html b/doc/archive_reference.html index d0ab60b29..f888cbfb1 100644 --- a/doc/archive_reference.html +++ b/doc/archive_reference.html @@ -411,6 +411,15 @@

Usage

serialize such a primitive type will result in a compilation error since the common polymorphic interface is static and cannot instantiate code for a new type. +

+Note also that every value written through a polymorphic archive has to be given a name, with +BOOST_SERIALIZATION_NVP or +make_nvp. Which archive is on the other end is settled +at run time, and it may turn out to be an XML one, where a value is written as an element and so +must be named. A templated XML archive rejects an unnamed value where it is written; the +polymorphic interface cannot, because at that point the archive type is not yet known, and the +value is written without an element around it. The resulting document cannot be read back. +

The main utility of polymorphic archives will be to permit the building of class DLLs that will include serialization code for all present and future archives with no redundant code.