I am stuck with this problem while compiling my static class library.
I know that Boost doesn't officially support VS2012 but since this is my current development environment, I could really use some advice.
I have been searching around but nothing so far has helped me.
Sample code:
Foo.h:
#include "FooImpl.h"
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
class Foo
{
public:
Foo(void) : pImpl(std::make_shared<FooImpl>()) {}
//similar constructors follow
//a few get methods here
private:
std::shared_ptr<FooImpl> pImpl;
friend class boost::serialization::access;
template <typename Archive>
void serialize(Archive & ar, const unsigned int file_version);
}
Foo.cpp:
#include "stdafx.h"
#include "Foo.h"
template<class Archive>
void Foo::serialize(Archive& ar, const unsigned int ver)
{
ar & pImpl;
}
template void Foo::serialize<boost::archive::text_iarchive>(
boost::archive::text_iarchive & ar,
const unsigned int file_version
);
template void Foo::serialize<boost::archive::text_oarchive>(
boost::archive::text_oarchive & ar,
const unsigned int file_version
);
FooImpl.h:
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/string.hpp>
class FooImpl
{
public:
FooImpl(void);
//other constructors, get methods
private:
//data members - unsigned int & std::wstring
friend class boost::serialization::access;
template <typename Archive>
void serialize(Archive& ar, const unsigned int ver);
};
FooImpl.cpp:
#include "stdafx.h"
#include "FooImpl.h"
//function implementations
template <typename Archive>
void FooImpl::serialize(Archive& ar, const unsigned int ver)
{
ar & id_;
ar & code_;
}
//Later added, serialization requires these
template void FooImpl::serialize<boost::archive::text_iarchive>(
boost::archive::text_iarchive & ar,
const unsigned int file_version
);
template void FooImpl::serialize<boost::archive::text_oarchive>(
boost::archive::text_oarchive & ar,
const unsigned int file_version
);