J.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef BOOST_SERIALIZATION_TEST_J_HPP
  2. #define BOOST_SERIALIZATION_TEST_J_HPP
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER)
  5. # pragma once
  6. #endif
  7. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  8. // J.hpp simple class test
  9. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  10. // Use, modification and distribution is subject to the Boost Software
  11. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. // See http://www.boost.org for updates, documentation, and revision history.
  14. #include <boost/serialization/base_object.hpp>
  15. #include "A.hpp"
  16. ///////////////////////////////////////////////////////
  17. // class with a member which refers to itself
  18. class J : public A
  19. {
  20. private:
  21. friend class boost::serialization::access;
  22. template<class Archive>
  23. void serialize(
  24. Archive &ar,
  25. const unsigned int /* file_version */
  26. ){
  27. ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(A);
  28. ar & BOOST_SERIALIZATION_NVP(j);
  29. }
  30. public:
  31. bool operator==(const J &rhs) const;
  32. J *j;
  33. J(J *_j) : j(_j) {}
  34. J() : j(NULL){}
  35. };
  36. BOOST_CLASS_VERSION(J, 6)
  37. bool J::operator==(const J &rhs) const
  38. {
  39. return static_cast<const A &>(*this) == static_cast<const A &>(rhs);
  40. }
  41. #endif // BOOST_SERIALIZATION_TEST_J_HPP