Complex.hpp 838 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ///
  2. /// \file Archive/Pair.hpp
  3. ///
  4. /// Complex support for serialization.
  5. ///
  6. /// \copyright
  7. /// Copyright (c) 2016 Josh Blum
  8. /// SPDX-License-Identifier: BSL-1.0
  9. ///
  10. #pragma once
  11. #include <Pothos/Config.hpp>
  12. #include <Pothos/Archive/Invoke.hpp>
  13. #include <complex> //pair
  14. namespace Pothos {
  15. namespace serialization {
  16. template<typename Archive, typename T>
  17. void save(Archive &ar, const std::complex<T> &t, const unsigned int)
  18. {
  19. ar << t.real();
  20. ar << t.imag();
  21. }
  22. template<typename Archive, typename T>
  23. void load(Archive &ar, std::complex<T> &t, const unsigned int)
  24. {
  25. T real, imag;
  26. ar >> real;
  27. ar >> imag;
  28. t.real(real);
  29. t.imag(imag);
  30. }
  31. template <typename Archive, typename T>
  32. void serialize(Archive &ar, std::complex<T> &t, const unsigned int ver)
  33. {
  34. Pothos::serialization::invokeSplit(ar, t, ver);
  35. }
  36. }}