| 1 |
|
|---|
| 2 | #include <sstream>
|
|---|
| 3 | #include <string>
|
|---|
| 4 | #include <vector>
|
|---|
| 5 |
|
|---|
| 6 | #include <boost/archive/text_iarchive.hpp>
|
|---|
| 7 | #include <boost/archive/text_oarchive.hpp>
|
|---|
| 8 | #include <boost/serialization/vector.hpp>
|
|---|
| 9 |
|
|---|
| 10 | template<typename Archive>
|
|---|
| 11 | struct X
|
|---|
| 12 | {
|
|---|
| 13 | template<typename T>
|
|---|
| 14 | void operator<<(const T &t)
|
|---|
| 15 | {
|
|---|
| 16 | Archive &archive = (*(Archive *) NULL);
|
|---|
| 17 | archive << t;
|
|---|
| 18 | }
|
|---|
| 19 | };
|
|---|
| 20 |
|
|---|
| 21 | void dummy()
|
|---|
| 22 | {
|
|---|
| 23 | typedef boost::archive::text_oarchive Archive;
|
|---|
| 24 | X<Archive> &x = * (X<Archive> *) NULL;
|
|---|
| 25 | std::vector<char> *pt = NULL;
|
|---|
| 26 |
|
|---|
| 27 | // uncomment this line to cause the test to fail
|
|---|
| 28 | //x << pt;
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | int main(int argc, char* argv[])
|
|---|
| 32 | {
|
|---|
| 33 | std::vector<char> v0(25, '%');
|
|---|
| 34 | std::vector<char> v1;
|
|---|
| 35 |
|
|---|
| 36 | std::ostringstream ostr;
|
|---|
| 37 | boost::archive::text_oarchive(ostr) & v0;
|
|---|
| 38 |
|
|---|
| 39 | std::istringstream istr(ostr.str());
|
|---|
| 40 | boost::archive::text_iarchive(istr) & v1;
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | bool ok = (v0 == v1);
|
|---|
| 44 | return 0;
|
|---|
| 45 | }
|
|---|