| 1 | #include <fstream>
|
|---|
| 2 | #include <boost/serialization/base_object.hpp>
|
|---|
| 3 | #include <boost/archive/text_oarchive.hpp>
|
|---|
| 4 |
|
|---|
| 5 | // A class, which must not be used as base class (e.g. because the destructor is not
|
|---|
| 6 | // virtual).
|
|---|
| 7 | class Foo final{
|
|---|
| 8 | public:
|
|---|
| 9 | template<class ArchiveType>
|
|---|
| 10 | void serialize(ArchiveType& rArchive,const unsigned int Version){
|
|---|
| 11 | }
|
|---|
| 12 | };
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | void main(){
|
|---|
| 16 | // Create an instance of Foo
|
|---|
| 17 | Foo Instance;
|
|---|
| 18 | // Serialize it to a text archive
|
|---|
| 19 | std::fstream OutputFile("OutputFile.txt");
|
|---|
| 20 | if(OutputFile.is_open()){
|
|---|
| 21 | boost::archive::text_oarchive OutputArchive(OutputFile);
|
|---|
| 22 | // Templates instantiated due to the next line cause the following error,
|
|---|
| 23 | // when compiling with Visual Studio 2012 SP1:
|
|---|
| 24 | // [...]boost\type_traits\is_polymorphic.hpp(46): error C3246:
|
|---|
| 25 | // 'boost::detail::is_polymorphic_imp1<T>::d2' : cannot inherit from 'Foo'
|
|---|
| 26 | // as it has been declared as 'final'
|
|---|
| 27 | OutputArchive<<Instance;
|
|---|
| 28 | }
|
|---|
| 29 | }
|
|---|