Skip to content

Document that a derived archive must call init() itself#357

Merged
gennaroprota merged 1 commit into
developfrom
doc/archive-derivation-init
Jul 23, 2026
Merged

Document that a derived archive must call init() itself#357
gennaroprota merged 1 commit into
developfrom
doc/archive-derivation-init

Conversation

@gennaroprota

Copy link
Copy Markdown
Collaborator

Since Boost 1.73, the CRTP base archive classes no longer call init() from their constructors: doing so downcast this to the most derived class while it was still being constructed, which is undefined behavior and tripped the sanitizers. The derivation guide still showed the old pattern, in which a class derived from one of the xxx_oarchive_impl templates relied on the base to write the archive header. Following it now yields an archive that never writes its header.

The guide now states that the most derived class is responsible for calling init() in its own constructor body, honoring no_header, and shows how, noting that the log_archive example is empty only because it suppresses the header.

This also corrects the curiously recurring template argument in the further-derivation sketch, which named xml_oarchive instead of log_archive.

Refs issue #182.

Since Boost 1.73, the CRTP base archive classes no longer call `init()`
from their constructors: doing so downcast this to the most derived
class while it was still being constructed, which is undefined behavior
and tripped the sanitizers. The derivation guide still showed the old
pattern, in which a class derived from one of the `xxx_oarchive_impl`
templates relied on the base to write the archive header. Following it
now yields an archive that never writes its header.

The guide now states that the most derived class is responsible for
calling `init()` in its own constructor body, honoring `no_header`, and
shows how, noting that the log_archive example is empty only because it
suppresses the header.

This also corrects the curiously recurring template argument in the
further-derivation sketch, which named `xml_oarchive` instead of
`log_archive`.

Refs issue #182.
@gennaroprota
gennaroprota added this pull request to the merge queue Jul 23, 2026
Merged via the queue into develop with commit f8e5ca8 Jul 23, 2026
85 of 86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant