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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:14:28+00:00 2026-06-12T15:14:28+00:00

I have a problem in an application i’m doing. I need to serialize some

  • 0

I have a problem in an application i’m doing. I need to serialize some packets using boost serialization. According to the documentation, one can use BOOST_CLASS_EXPORT_KEY and BOOST_CLASS_EXPORT_IMPLEMENT respectively into .hpp and .cpp files to be able to use polymorphic base pointer to serialize derived class.

So here is what I have:

.hpp: containaing my class declaration and finaly the BOOST_CLASS_EXPORT_KEY(mynamespace::mypacket)

.cpp: containing my class definition and the BOOST_CLASS_EXPORT_IMPLEMENT(mynamespace::mypacket)

Everything runs fine till this point but when needing to serialize I get a bad_alloc error.

I worked arround this problem by explicitly calling the method register_type<mypacket>() on the archive i need to use.

But here is my question : Is the EXPORT* of boost meant to avoid calls to register_type method or am I doing something wrong? I kind of feel like doing twice the same work in my code, but more than that I don’t see any advantage of using export key + implement if we still have to use register_type on archive after!

I read some other posts here and elsewhere, it seems I’m not the only one to experiment the problem, but I have not found any answer yet.

  • 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-12T15:14:29+00:00Added an answer on June 12, 2026 at 3:14 pm

    i figured out how to avoid calling register_type on archive. For those who might be interested, it is needed to do template serialization specialization as well as exporting key + implement.

    So here is what your .hpp should look like :

    • class declaration (mynamespace::myclass)
    • class export : BOOST_CLASS_EXPORT_KEY(mynamespace::myclass)

    And in the cpp:

    • class definiton
    • class export : BOOST_CLASS_EXPORT_IMPLEMENT(mynamespace::myclass)
    • AND : serialize() member specialization on the archive you need to use, for each class :

    template void mynamespace::mypacket::serialize(boost::archive::text_iarchive& arch, const unsigned int version);

    template void mynamespace::mypacket::serialize(boost::archive::text_oarchive& arch, const unsigned int version);

    Where boost::archive::text_(i/o)archive should be replaced with whatever kind of boost archive you are using.

    In hope it will help someone someday (this is clearly written in the boost documentation, but i must have missed it till today…)

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

Sidebar

Related Questions

I have one problem in my application. I need to create two CSV files
I have problem with using next two properties together in one Air application, I
I have some problem with my application, I have 4 buttons, one to start
I have problem doing OTA installation for my iPad application. I updated my enterprise
i have a problem to distributing application with 2 project (one project with sub-project
I have problem concerning python packages and testing. I'm writing an application using wx
I have problem with win application when more then one network cards is plugged
I have problem occuring in my application.. Using XML file i am getting geopoints
I have problem with my Android application. I need an application that will send
I have a problem in my application I am using MVC 3 with razor

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.