is_bitwise_serializable.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // (C) Copyright 2007 Matthias Troyer
  2. // Use, modification and distribution is subject to the Boost Software
  3. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Authors: Matthias Troyer
  6. /** @file is_bitwise_serializable.hpp
  7. *
  8. * This header provides a traits class for determining whether a class
  9. * can be serialized (in a non-portable way) just by copying the bits.
  10. */
  11. #ifndef BOOST_SERIALIZATION_IS_BITWISE_SERIALIZABLE_HPP
  12. #define BOOST_SERIALIZATION_IS_BITWISE_SERIALIZABLE_HPP
  13. // MS compatible compilers support #pragma once
  14. #if defined(_MSC_VER)
  15. # pragma once
  16. #endif
  17. #include <boost/mpl/bool_fwd.hpp>
  18. #include <boost/type_traits/is_arithmetic.hpp>
  19. namespace boost {
  20. namespace serialization {
  21. template<class T>
  22. struct is_bitwise_serializable
  23. : public is_arithmetic< T >
  24. {};
  25. } // namespace serialization
  26. } // namespace boost
  27. // define a macro to make explicit designation of this more transparent
  28. #define BOOST_IS_BITWISE_SERIALIZABLE(T) \
  29. namespace boost { \
  30. namespace serialization { \
  31. template<> \
  32. struct is_bitwise_serializable< T > : mpl::true_ {}; \
  33. }} \
  34. /**/
  35. #endif //BOOST_SERIALIZATION_IS_BITWISE_SERIALIZABLE_HPP