Ticket #11245: not_default_constructible.cpp

File not_default_constructible.cpp, 996 bytes (added by Tony Lewis <tonyelewis@…>, 7 years ago)

Shows v1.58.0 compilation failure on attempt to serialize vector of non-default-constructible class

Line 
1#include <boost/archive/xml_iarchive.hpp>
2#include <boost/serialization/vector.hpp>
3
4#include <vector>
5#include <fstream>
6
7using namespace std;
8
9class non_def_ctable {
10private:
11 friend class boost::serialization::access;
12
13 template<class Archive>
14 void serialize(Archive& ar, const unsigned int) { ar & BOOST_SERIALIZATION_NVP( value ); }
15
16 int value;
17
18public:
19 non_def_ctable() = delete;
20 non_def_ctable(int arg_value) : value( arg_value ) {}
21};
22
23namespace boost {
24 namespace serialization {
25 template <typename Archive>
26 inline void load_construct_data(Archive &,
27 non_def_ctable * t,
28 const unsigned int
29 ) {
30 ::new(t)non_def_ctable( 0 );
31 }
32 }
33}
34
35int main() {
36 ifstream the_input_stream;
37 boost::archive::xml_iarchive the_input_archive( the_input_stream );
38
39 vector<non_def_ctable> non_def_ctables;
40
41 the_input_archive & BOOST_SERIALIZATION_NVP( non_def_ctables );
42}
43