Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8696141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:12:35+00:00 2026-06-13T01:12:35+00:00

I am in need of a Boost::Serialization specialization for std::shared_ptr. I am writing a

  • 0

I am in need of a Boost::Serialization specialization for std::shared_ptr.

I am writing a program that sends objects over Boost::Asio and many of those objects use shared_ptrs internally. Using a workaround to only serialize the objects they are referring to is quite uncomfortable.

I have been trying to make my own, looking at the implementation provided for Boost::shared_ptr but I lack the understanding of how those objects should be handled.

Changing the namespaces in Boost::shared_ptr serialization made it possible to serialize the pointer but deserialization doesn’t work for me.

As a last resort, I could(and maybe should) switch over to using std::unique_ptrs for my objects, because, at the moment, it seems they own them, but that would lead me to the same problem, only with unique_ptr.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:12:37+00:00Added an answer on June 13, 2026 at 1:12 am

    I am not sure if this is the best way to do this but it seems to work.

    Changed the namespace and added this load method to shared_ptr specialization header copied from Boost::shared_ptr specialization:

    template<class Archive, class T>
    inline void load(
        Archive & ar,
        std::shared_ptr< T > &t,
        const unsigned int /* file_version */
    ){
        T * t_ptr;
        ar >> boost::serialization::make_nvp("px", t_ptr);
        t = std::shared_ptr<T>(t_ptr);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a container of pointers. Would you recommend boost::ptr_vector<T> or std::vector<boost::shared_ptr<T> > ?
I am working on a client-server application that uses boost::serialization library for it's serialization
For reasons that I will gloss over, I need to set aside space of
I need to detect whether a particular file is binary file saved by boost::serialization.
I need to use the boost serialization code. I am in the process of
I need to serialize std::wstring by my own method. How to force boost to
I need to build boost program options static library in both PC/Mac. It has
Ok, I need a boost on this thought process - my brain hurts. I'd
I'm new in using boost and have a problem. I need shared_mutex function in
i need to serialize directory tree. i have no trouble with this type: std::map<

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.