Skip to content

Stop the shared pointer helper from declaring a load overload - #372

Merged
gennaroprota merged 1 commit into
developfrom
fix/shared-ptr-helper-declares-no-load-overload
Aug 7, 2026
Merged

Stop the shared pointer helper from declaring a load overload#372
gennaroprota merged 1 commit into
developfrom
fix/shared-ptr-helper-declares-no-load-overload

Conversation

@gennaroprota

Copy link
Copy Markdown
Collaborator

The declaration existed only to let the load functions in shared_ptr.hpp and shared_ptr_132.hpp be granted friendship, and it was malformed: it contained SPT< class U >, which is an elaborated type specifier, so it declared an undefined class boost::serialization::U and pinned the parameter to SPT<U> for that one type. Deducing against it forms types such as std::optional<U>, whose instantiation needs U complete, so serializing a std::optional alongside shared_ptr.hpp failed to compile under GCC.

But repairing the declaration was not enough: the corrected declaration matched every class template taking a single type argument, and turned ambiguous against the load for std::vector. So, this drops the declaration and the friendship together instead, leaving public the members the two headers reach for, as they already were for Microsoft and Sun compilers.

Fixes #319.

The declaration existed only to let the load functions in shared_ptr.hpp
and shared_ptr_132.hpp be granted friendship, and it was malformed: it
contained `SPT< class U >`, which is an elaborated type specifier, so it
declared an undefined class `boost::serialization::U` and pinned the
parameter to `SPT<U>` for that one type.  Deducing against it forms
types such as `std::optional<U>`, whose instantiation needs `U`
complete, so serializing a `std::optional` alongside `shared_ptr.hpp`
failed to compile under GCC.

But repairing the declaration was not enough: the corrected declaration
matched every class template taking a single type argument, and turned
ambiguous against the `load` for `std::vector`.  So, this drops the
declaration and the friendship together instead, leaving public the
members the two headers reach for, as they already were for Microsoft
and Sun compilers.

Fixes #319.
@gennaroprota
gennaroprota added this pull request to the merge queue Aug 7, 2026
Merged via the queue into develop with commit 77dbdc0 Aug 7, 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.

std::optional serialization conflicts with boost::shared_ptr in Boost 1.84 and 1.85

1 participant