Skip to content

Cover optional of a type with a private default constructor#355

Merged
gennaroprota merged 1 commit into
developfrom
test/optional-of-type-with-private-default-constructor
Jul 22, 2026
Merged

Cover optional of a type with a private default constructor#355
gennaroprota merged 1 commit into
developfrom
test/optional-of-type-with-private-default-constructor

Conversation

@gennaroprota

Copy link
Copy Markdown
Collaborator

This adds a regression test for an optional whose value type keeps its default constructor private and grants friendship to boost::serialization::access. Such a type is not default constructible from the trait's point of view, so it takes the same reconstruct-on-load path as any other non-default-constructible type: the value is built through load_construct_data, whose default calls access::construct, and access reaches the private constructor. Before this, the archive demanded a publicly accessible default constructor, which broke this design.

The type is exercised for both boost::optional and std::optional across every archive type.

Closes issue #165.

This adds a regression test for an optional whose value type keeps its
default constructor private and grants friendship to
`boost::serialization::access`. Such a type is not default constructible
from the trait's point of view, so it takes the same reconstruct-on-load
path as any other non-default-constructible type: the value is built
through `load_construct_data`, whose default calls `access::construct`,
and access reaches the private constructor. Before this, the archive
demanded a publicly accessible default constructor, which broke this
design.

The type is exercised for both `boost::optional` and `std::optional`
across every archive type.

Closes issue #165.
@gennaroprota
gennaroprota added this pull request to the merge queue Jul 22, 2026
Merged via the queue into develop with commit 4ef61fe Jul 22, 2026
43 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