Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 08:28:17

0001 #ifndef BOOST_UUID_DETAIL_UUID_GENERIC_IPP_INCLUDED
0002 #define BOOST_UUID_DETAIL_UUID_GENERIC_IPP_INCLUDED
0003 
0004 // Copyright 2024 Peter Dimov
0005 // Distributed under the Boost Software License, Version 1.0.
0006 // https://www.boost.org/LICENSE_1_0.txt
0007 
0008 #include <boost/uuid/detail/endian.hpp>
0009 #include <cstdint>
0010 
0011 #if defined(BOOST_UUID_REPORT_IMPLEMENTATION)
0012 
0013 #include <boost/config/pragma_message.hpp>
0014 BOOST_PRAGMA_MESSAGE( "Using uuid_generic.ipp" )
0015 
0016 #endif
0017 
0018 namespace boost {
0019 namespace uuids {
0020 
0021 inline bool uuid::is_nil() const noexcept
0022 {
0023     std::uint64_t v = detail::load_native_u64( this->data + 0 );
0024     std::uint64_t w = detail::load_native_u64( this->data + 8 );
0025 
0026     return v == 0 && w == 0;
0027 }
0028 
0029 inline void uuid::swap( uuid& rhs ) noexcept
0030 {
0031     std::uint64_t v1 = detail::load_native_u64( this->data + 0 );
0032     std::uint64_t w1 = detail::load_native_u64( this->data + 8 );
0033 
0034     std::uint64_t v2 = detail::load_native_u64( rhs.data + 0 );
0035     std::uint64_t w2 = detail::load_native_u64( rhs.data + 8 );
0036 
0037     detail::store_native_u64( this->data + 0, v2 );
0038     detail::store_native_u64( this->data + 8, w2 );
0039 
0040     detail::store_native_u64( rhs.data + 0, v1 );
0041     detail::store_native_u64( rhs.data + 8, w1 );
0042 }
0043 
0044 inline bool operator==( uuid const& lhs, uuid const& rhs ) noexcept
0045 {
0046     std::uint64_t v1 = detail::load_native_u64( lhs.data + 0 );
0047     std::uint64_t w1 = detail::load_native_u64( lhs.data + 8 );
0048 
0049     std::uint64_t v2 = detail::load_native_u64( rhs.data + 0 );
0050     std::uint64_t w2 = detail::load_native_u64( rhs.data + 8 );
0051 
0052     return v1 == v2 && w1 == w2;
0053 }
0054 
0055 inline bool operator<( uuid const& lhs, uuid const& rhs ) noexcept
0056 {
0057     std::uint64_t v1 = detail::load_big_u64( lhs.data + 0 );
0058     std::uint64_t w1 = detail::load_big_u64( lhs.data + 8 );
0059 
0060     std::uint64_t v2 = detail::load_big_u64( rhs.data + 0 );
0061     std::uint64_t w2 = detail::load_big_u64( rhs.data + 8 );
0062 
0063     return v1 < v2 || ( !( v2 < v1 ) && w1 < w2 );
0064 }
0065 
0066 #if defined(BOOST_UUID_HAS_THREE_WAY_COMPARISON)
0067 
0068 inline std::strong_ordering operator<=> (uuid const& lhs, uuid const& rhs) noexcept
0069 {
0070     std::uint64_t v1 = detail::load_big_u64( lhs.data + 0 );
0071     std::uint64_t w1 = detail::load_big_u64( lhs.data + 8 );
0072 
0073     std::uint64_t v2 = detail::load_big_u64( rhs.data + 0 );
0074     std::uint64_t w2 = detail::load_big_u64( rhs.data + 8 );
0075 
0076     if( v1 < v2 ) return std::strong_ordering::less;
0077     if( v1 > v2 ) return std::strong_ordering::greater;
0078 
0079     return w1 <=> w2;
0080 }
0081 
0082 #endif
0083 
0084 } // namespace uuids
0085 } // namespace boost
0086 
0087 #endif // BOOST_UUID_DETAIL_UUID_GENERIC_IPP_INCLUDED