uuid_generic.ipp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright Andy Tompkins 2006.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * https://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file uuid/detail/uuid_generic.ipp
  9. *
  10. * \brief This header contains generic implementation of \c boost::uuid operations.
  11. */
  12. #ifndef BOOST_UUID_DETAIL_UUID_GENERIC_IPP_INCLUDED_
  13. #define BOOST_UUID_DETAIL_UUID_GENERIC_IPP_INCLUDED_
  14. #include <string.h>
  15. namespace boost {
  16. namespace uuids {
  17. inline bool uuid::is_nil() const BOOST_NOEXCEPT
  18. {
  19. for (std::size_t i = 0; i < sizeof(data); ++i)
  20. {
  21. if (data[i] != 0U)
  22. return false;
  23. }
  24. return true;
  25. }
  26. inline void uuid::swap(uuid& rhs) BOOST_NOEXCEPT
  27. {
  28. uuid tmp = *this;
  29. *this = rhs;
  30. rhs = tmp;
  31. }
  32. inline bool operator== (uuid const& lhs, uuid const& rhs) BOOST_NOEXCEPT
  33. {
  34. return memcmp(lhs.data, rhs.data, sizeof(lhs.data)) == 0;
  35. }
  36. inline bool operator< (uuid const& lhs, uuid const& rhs) BOOST_NOEXCEPT
  37. {
  38. return memcmp(lhs.data, rhs.data, sizeof(lhs.data)) < 0;
  39. }
  40. } // namespace uuids
  41. } // namespace boost
  42. #endif // BOOST_UUID_DETAIL_UUID_GENERIC_IPP_INCLUDED_