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 6362181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:52:33+00:00 2026-05-24T23:52:33+00:00

Just a tid bit of information that doesn’t seem documented anywhere. Does anyone know?

  • 0

Just a tid bit of information that doesn’t seem documented anywhere. Does anyone know? Because I would like to make it private, hoping that the constructor would be called from boost::serialization::access which is declared as a friend.

  • 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-05-24T23:52:34+00:00Added an answer on May 24, 2026 at 11:52 pm

    Test example. Given that this works I’d assume it is a feature and would be upset if there was a future release that didn’t allow the access granting mechanism to grant access to private default constructors.

    #include <boost/serialization/access.hpp>
    #include <boost/serialization/shared_ptr.hpp>
    #include <boost/shared_ptr.hpp>
    #include <boost/archive/text_iarchive.hpp>
    #include <boost/archive/text_oarchive.hpp>
    #include <sstream>
    #include <iostream>
    
    struct Colour {
        double colour[4];
        boost::shared_ptr<Colour> alt;
        static boost::shared_ptr<Colour> test() {
           return boost::shared_ptr<Colour>(new Colour);
        }
    private:
        friend class boost::serialization::access;
    
        template<class Archive>
        void serialize(Archive & ar, const unsigned int /*file_version*/) {
            ar & colour;
        }
    
        Colour() {
            std::cout << "Getting called" << std::endl;
        }
    };
    
    int main() {
        boost::shared_ptr<Colour> c = Colour::test();
        c->alt = Colour::test();
    
        std::cout << "Created" << std::endl;
    
        std::stringstream str;
        boost::archive::text_oarchive oa(str);
        oa & c;
    
        std::cout << "Saved" << std::endl;
    
        c.reset();
    
        boost::archive::text_iarchive ia(str);
        ia & c;
    
        std::cout << "Restored" << std::endl;
    }
    

    (Interestingly it seems to default construct one and then copy construct another on my system).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just curious about what would be the django way of achieving the following :
Just getting started with backbone.js, and one of the things I've noticed is that
Just a note upfront: I'm a bit of a regex newbie. Perhaps a good
I'm just trying to restrict block visibility to nodes that have a certain taxonomy
I sniffed a bit when sent a message to a friend and found that
I need to know if in a database in Sql Server 2008 (would also
I have an interface called Identifiable<TId> that contains a single property Id of the
Just wondering is there a way to handle that in Sencha Touch. One store
Just a quick one, hopefully. I've coded up this: <script> $(div.design-project).css('display', 'none'); function InsertContent(tid)
I've just come across this in a WHERE clause: AND NOT (t.id = @id)

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.