|
Boost Users : |
From: Klaus Nowikow (nowikow_at_[hidden])
Date: 2005-04-18 12:34:14
Hello all,
when I compile the code below (with MSVC 7.1), I get an error telling me that
"'serialize' : is not a member of 'std::vector<_Ty>'". I will post the
exact error message below the code.
The strange thing about this is that when I change the #define TEST
line to #define TEST 1 (or 2 or 3), it compiles ok [1 means that only
the iarchive is used, 2 that the oarchive is used, and 3 that a 'B'
object is serialized instead of an 'A' object].
Is there anything wrong with the code?
Thanks and best regards,
Klaus
<code>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <sstream>
#define TEST 0 // Change this to 1, 2, or 3
struct C
{
int m_;
template <class Archive>
void serialize(Archive& ar, size_t i)
{
ar & BOOST_SERIALIZATION_NVP(this->m_);
}
};
struct B
{
std::vector<C> m_;
template <class Archive>
void serialize(Archive& ar, size_t i)
{
ar & BOOST_SERIALIZATION_NVP(this->m_);
}
};
struct A
{
B m_;
template <class Archive>
void serialize(Archive& ar, size_t i)
{
ar & BOOST_SERIALIZATION_NVP(this->m_);
}
};
void save()
{
#if TEST != 3
A object;
#else
B object;
#endif
std::stringstream str;
boost::archive::binary_oarchive ar(str);
#if TEST != 1
ar << BOOST_SERIALIZATION_NVP(object);
#endif
}
void load()
{
#if TEST != 3
A object;
#else
B object;
#endif
std::stringstream str;
boost::archive::binary_iarchive ar(str);
#if TEST != 2
ar >> BOOST_SERIALIZATION_NVP(object);
#endif
}
int main(int, char**)
{
return 0;
}
</code>
<errormessage>
../../Libraries\Boost\include\boost-1_32\boost\serialization\access.hpp(106) : error C2039: 'serialize' : is not a member of 'std::vector<_Ty>'
with
[
_Ty=C
]
../../Libraries\Boost\include\boost-1_32\boost\serialization\serialization.hpp(78) : see reference to function template instantiation 'void boost::serialization::access::serialize<Archive,T>(Archive &,T &,const unsigned int)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=std::vector<C>
]
../../Libraries\Boost\include\boost-1_32\boost\serialization\serialization.hpp(121) : see reference to function template instantiation 'void boost::serialization::serialize<Archive,T>(Archive &,T &,const unsigned int)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=std::vector<C>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\iserializer.hpp(159) : see reference to function template instantiation 'void boost::serialization::serialize_adl<Archive,T>(Archive &,T &,const unsigned int)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=std::vector<C>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\iserializer.hpp(109) : while compiling class-template member function 'void boost::archive::detail::iserializer<Archive,T>::load_object_data(boost::archive::detail::basic_iarchive &,void *,const unsigned int) const'
with
[
Archive=boost::archive::binary_iarchive,
T=std::vector<C>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\iserializer.hpp(328) : see reference to class template instantiation 'boost::archive::detail::iserializer<Archive,T>' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=std::vector<C>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\iserializer.hpp(326) : while compiling class-template member function 'void boost::archive::detail::load_non_pointer_type<Archive,T>::load::invoke(Archive &,T &)'
with
[
Archive=boost::archive::binary_iarchive,
T=std::vector<C>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\iserializer.hpp(366) : see reference to class template instantiation 'boost::archive::detail::load_non_pointer_type<Archive,T>::load' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=std::vector<C>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\iserializer.hpp(331) : while compiling class-template member function 'void boost::archive::detail::load_non_pointer_type<Archive,T>::invoke(Archive &,T &)'
with
[
Archive=boost::archive::binary_iarchive,
T=std::vector<C>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\iserializer.hpp(529) : see reference to class template instantiation 'boost::archive::detail::load_non_pointer_type<Archive,T>' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=std::vector<C>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\basic_binary_iarchive.hpp(66) : see reference to function template instantiation 'void boost::archive::load<Archive,T>(Archive &,T &)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=std::vector<C>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\binary_iarchive.hpp(45) : see reference to function template instantiation 'void boost::archive::basic_binary_iarchive<Archive>::load_override<T>(T &,int)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=std::vector<C>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\interface_iarchive.hpp(92) : see reference to function template instantiation 'void boost::archive::binary_iarchive_impl<Archive>::load_override<T>(T &,int)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=std::vector<C>
]
../../Libraries\Boost\include\boost-1_32\boost\serialization\nvp.hpp(58) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_iarchive<Archive>::operator &<T>(T &)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=std::vector<C>
]
../../Libraries\Boost\include\boost-1_32\boost\serialization\access.hpp(106) : see reference to function template instantiation 'void boost::serialization::nvp<T>::serialize<Archive>(Archive &,const unsigned int) const' being compiled
with
[
T=std::vector<C>,
Archive=boost::archive::binary_iarchive
]
../../Libraries\Boost\include\boost-1_32\boost\serialization\serialization.hpp(78) : see reference to function template instantiation 'void boost::serialization::access::serialize<Archive,T>(Archive &,T &,const unsigned int)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=boost::serialization::nvp<std::vector<C>>
]
../../Libraries\Boost\include\boost-1_32\boost\serialization\serialization.hpp(121) : see reference to function template instantiation 'void boost::serialization::serialize<Archive,T>(Archive &,T &,const unsigned int)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=boost::serialization::nvp<std::vector<C>>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\iserializer.hpp(320) : see reference to function template instantiation 'void boost::serialization::serialize_adl<Archive,T>(Archive &,T &,const unsigned int)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=boost::serialization::nvp<std::vector<C>>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\iserializer.hpp(314) : while compiling class-template member function 'void boost::archive::detail::load_non_pointer_type<Archive,T>::load_only::invoke(Archive &,T &)'
with
[
Archive=boost::archive::binary_iarchive,
T=boost::serialization::nvp<std::vector<C>>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\iserializer.hpp(366) : see reference to class template instantiation 'boost::archive::detail::load_non_pointer_type<Archive,T>::load_only' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=boost::serialization::nvp<std::vector<C>>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\iserializer.hpp(331) : while compiling class-template member function 'void boost::archive::detail::load_non_pointer_type<Archive,T>::invoke(Archive &,T &)'
with
[
Archive=boost::archive::binary_iarchive,
T=boost::serialization::nvp<std::vector<C>>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\iserializer.hpp(529) : see reference to class template instantiation 'boost::archive::detail::load_non_pointer_type<Archive,T>' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=boost::serialization::nvp<std::vector<C>>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\basic_binary_iarchive.hpp(66) : see reference to function template instantiation 'void boost::archive::load<Archive,T>(Archive &,T &)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=boost::serialization::nvp<std::vector<C>>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\binary_iarchive.hpp(45) : see reference to function template instantiation 'void boost::archive::basic_binary_iarchive<Archive>::load_override<T>(T &,int)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=boost::serialization::nvp<std::vector<C>>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\interface_iarchive.hpp(105) : see reference to function template instantiation 'void boost::archive::binary_iarchive_impl<Archive>::load_override<T>(T &,int)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=boost::serialization::nvp<std::vector<C>>
]
../../Libraries\Boost\include\boost-1_32\boost\archive\detail\interface_iarchive.hpp(111) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_iarchive<Archive>::operator >><T>(const T &)' being compiled
with
[
Archive=boost::archive::binary_iarchive,
T=boost::serialization::nvp<std::vector<C>>
]
</errormessage>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net