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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:57:04+00:00 2026-06-15T23:57:04+00:00

I recently wanted to serialize a class containing vector of objects. I’ve read in

  • 0

I recently wanted to serialize a class containing vector of objects. I’ve read in the documentation that if I include #include <boost/serialization/vector.hpp>, I’ll be able to do it with a simple & operator. Unfortunately, although compiler agrees to build the serializing code, it won’t allow me to compile the deserializing testcase. What might be wrong there?

#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/vector.hpp>

#include <fstream>

class A
{
        friend class boost::serialization::access;
        template<class Archive>
                void serialize(Archive & ar, const unsigned int version) const
                {
                }
};

class B
{

        friend class boost::serialization::access;

        template<class Archive>
                void serialize(Archive & ar, const unsigned int version) const
                {
                        ar & a;
                }

        std::vector<A> a;
};

int main()
{
        std::ifstream ifs("filename");
        boost::archive::text_iarchive ia(ifs);
        B b;
        ia >> b;

}

Below are the compiler’s errors:

> make testcase
g++ -ggdb -fpermissive    testcase.cpp   -o testcase
In file included from /usr/include/boost/archive/detail/oserializer.hpp:67:0,
                 from /usr/include/boost/archive/detail/interface_oarchive.hpp:23,
                 from /usr/include/boost/archive/detail/common_oarchive.hpp:22,
                 from /usr/include/boost/archive/basic_text_oarchive.hpp:32,
                 from /usr/include/boost/archive/text_oarchive.hpp:31,
                 from testcase.cpp:1:
/usr/include/boost/archive/detail/check.hpp: In instantiation of ‘void boost::archive::detail::check_const_loading() [with T = const std::vector<A>]’:
/usr/include/boost/archive/detail/iserializer.hpp:577:5:   required from ‘void boost::archive::load(Archive&, T&) [with Archive = boost::archive::text_iarchive; T = const std::vector<A>]’
/usr/include/boost/archive/detail/common_iarchive.hpp:66:9:   required from ‘void boost::archive::detail::common_iarchive<Archive>::load_override(T&, int) [with T = const std::vector<A>; Archive = boost::archive::text_iarchive]’
/usr/include/boost/archive/basic_text_iarchive.hpp:65:9:   required from ‘void boost::archive::basic_text_iarchive<Archive>::load_override(T&, int) [with T = const std::vector<A>; Archive = boost::archive::text_iarchive]’
/usr/include/boost/archive/text_iarchive.hpp:82:9:   required from ‘void boost::archive::text_iarchive_impl<Archive>::load_override(T&, int) [with T = const std::vector<A>; Archive = boost::archive::text_iarchive]’
/usr/include/boost/archive/detail/interface_iarchive.hpp:60:9:   required from ‘Archive& boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T = const std::vector<A>; Archive = boost::archive::text_iarchive]’
/usr/include/boost/archive/detail/interface_iarchive.hpp:67:35:   [ skipping 9 instantiation contexts ]
/usr/include/boost/archive/detail/iserializer.hpp:592:5:   required from ‘void boost::archive::load(Archive&, T&) [with Archive = boost::archive::text_iarchive; T = B]’
/usr/include/boost/archive/detail/common_iarchive.hpp:66:9:   required from ‘void boost::archive::detail::common_iarchive<Archive>::load_override(T&, int) [with T = B; Archive = boost::archive::text_iarchive]’
/usr/include/boost/archive/basic_text_iarchive.hpp:65:9:   required from ‘void boost::archive::basic_text_iarchive<Archive>::load_override(T&, int) [with T = B; Archive = boost::archive::text_iarchive]’
/usr/include/boost/archive/text_iarchive.hpp:82:9:   required from ‘void boost::archive::text_iarchive_impl<Archive>::load_override(T&, int) [with T = B; Archive = boost::archive::text_iarchive]’
/usr/include/boost/archive/detail/interface_iarchive.hpp:60:9:   required from ‘Archive& boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T = B; Archive = boost::archive::text_iarchive]’
testcase.cpp:35:8:   required from here
/usr/include/boost/archive/detail/check.hpp:162:1: error: invalid application of ‘sizeof’ to incomplete type ‘boost::STATIC_ASSERTION_FAILURE<false>’
  • 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-15T23:57:05+00:00Added an answer on June 15, 2026 at 11:57 pm

    The serialize member function should not be const. It is used to serialize, but to de-serialize too.

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

Sidebar

Related Questions

I've read about Single-Page Applications recently and wanted to try one out. After watching
This is something that's I've wanted to know recently, mostly out of curiousity. I'm
I recently wanted to use boost::algorithm::join but I couldn't find any usage examples and
I recently wanted use regex in Cocoa app. But I found that Cocoa does
I recently wanted to test my application on another computer that has the latest
I recently decided that I wanted all people who commit to my repository to
I've recently started learning HLSL after deciding that I wanted better lighting than what
I'm a long time PHP (CodeIgniter & WordPress) developer that only recently wanted to
Recently I got a client that wanted to have new features and a different
I recently decided that I wanted to try learning how to program in assembly.

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.