Hi, I am having difficulties in using boost serialization under
** Windows Vista 64bit **.   My boost libraries are built in 64bit.  (I
have attached the test program below)

It seems that boost serialization is not able to serialize uint64_t with
maximum value or anything larger then "14757395258967641292", as shown in main()   " check_serialization( test64t,
"boost::uint64_t" ); "

Also,  If I use multiple inheritance, like below, "YYConfig" and  "
typedef YYConfig <FakeC, FakeB> MyConfig;"  and trying to serialize
"MyConfig" , stream error can occurr.



Thank you very much for your help.


Best Regards,
Joseph


Here is my output


=========== uint32_t ================
succeeded
=========== boost::uint64_t ================
failed
Input : 18446744073709551615
Output : 14757395258967641292

The following will throw exception : stream error
//serialize_and_deserialize( cfg );
Press any key to continue . . .










Test Code
=====================================================================================
#include <iostream>
#include <boost/cstdint.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <sstream>
#include <cstdlib>

using namespace std;

template < class T1, class T2 >

struct YYConfig : public T1  , public T2   {
    public:
    	friend class boost::serialization::access;
    	template <class Archive>
    	void serialize(Archive & ar, const unsigned int version) {
				 ar & boost::serialization::base_object< T1 > (*this);
				 ar & boost::serialization::base_object< T2 > (*this);
		}
};



class FakeB
{
public:
	int x;

	FakeB(): x(0){}

	friend class boost::serialization::access;
    	template <class Archive>

    	void serialize(Archive & ar, const unsigned int version) {
			ar & x;
		}
};



class FakeC
{
public:
	boost::uint64_t targetNumSamples;
	friend class boost::serialization::access;

	FakeC() : targetNumSamples( std::numeric_limits< boost::uint64_t >::max() ){}

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







// ======================= Testing ================================/


template <typename T>
T serialize_and_deserialize( T typeValue1 )
{
	T typeValue2;

	// Set
	std::string content;
	std::ostringstream oss;
	{
		boost::archive::text_oarchive oa(oss);
		oa << typeValue1;
		content = oss.str();
	}

	// Extract
	std::istringstream iss( content );
	{
		boost::archive::text_iarchive ia( iss );
		ia >> typeValue2;
	}

	return typeValue2;
}



template <typename T>
bool check_serialization( T typeValue1, std::string testName )
{
	T typeValue2 = serialize_and_deserialize( typeValue1 );

	std::cout << std::endl << "=========== " << testName << " ================";

	if( typeValue1 == typeValue2 ){
		std::cout << std::endl << "succeeded ";
		return true;
	}
	else{
		std::cout << std::endl << "failed ";
		std::cout << std::endl << "Input : " << typeValue1;
		std::cout << std::endl << "Output : " << typeValue2;
		std::cout << std::endl;
		return false;
	}
}


typedef YYConfig <FakeC, FakeB> MyConfig;

int main(int argc, char** argv )
{
	boost::uint32_t test32t = std::numeric_limits< boost::uint32_t >::max();
	boost::uint64_t test64t = std::numeric_limits< boost::uint64_t >::max();
	
	
	check_serialization( test32t, "uint32_t" );
	check_serialization( test64t, "boost::uint64_t" );

	std::cout << std::endl  << "The following will throw exception : stream error" << std::endl ;
	system("pause");

	MyConfig cfg;
	serialize_and_deserialize( cfg );

	return 0;
}