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

  • Home
  • SEARCH
  • 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 4067672
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:16:45+00:00 2026-05-20T16:16:45+00:00

I have a templated container class that internally stores data in a following, static,

  • 0

I have a templated container class that internally stores data in a following, static, data variable:

template<typename T>
class Container {
  // ... Access methods
  std::map<unsigned int, std::map<unsigned int, boost::shared_ptr<T>>
};

The first unsigned int is an id of a Client using this collection, the second unsigned int is used to identify SubClient within the Client object. The Client object holds just the ids of SubClient’s and SubClient’s don’t hold any data themselves.

Now I need to save the whole client structure to a file. That is calling:

Client c;
/* Some operations on c */
c.Serialize(output);

should result in a file that contains the ids of SubClient’s and the associated data from the container classes. Now since the types that can be used in container classes can be of almost any type, and new types are being added and removed all the time from the codebase how can one serialize and deserialize such data?
The problem, how I see it, is in the fact that data types have no unique IDs that can be used to identify the part of a file as belonging to Container holding specific data nor can be ordered in any unambiguous way (or can they?).

How can I solve this with as little as possible changes in the data types used for containers.

  • 1 1 Answer
  • 2 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-20T16:16:45+00:00Added an answer on May 20, 2026 at 4:16 pm

    You’ve described what Boost.Serialization does perfectly. No changes to your containers or their data types should be necessary. The library has built-in support for serializing STL containers and boost::shared_ptr already. Though you may need to add serialization methods for T depending on what it is.

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

Sidebar

Related Questions

I have a templated container class that looks something like this: template <class ItemType>
I have my templated container class that looks like this: template< class KeyType, class
I have a particular class that stores a piece of data, which implements an
Let's suppose that I have a class container: template<class T, int size> class container
I have a web application where the masterPage/template contains some static HTML that never
I have an interface and a couple of implementations of a class that stores
I'm writing a templated C++ generic container class that can optionally maintain its contents
I have a C++ class Finder that stores a location in containers plus some
So I have a template class that I would like to accept an std::map
We have a structure like below: template<size_t size> class Container{ public: char characters[size]; };

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.