DDS-PSM-Cxx 1.1 RTF Avatar
  1. OMG Issue

DDSPSMC11_ — Reference should provide comparison operators

  • Key: DDSPSMC11_-12
  • Status: open  
  • Source: Real-Time Innovations ( Mr. Alejandro Campos)
  • Summary:

    dds::core::Reference<D> should provide comparison operators beyond == and !=. operator< is especially useful to make reference types the key of std::map.

    Proposed solution: add the following lines to Reference.hpp, inside the dds::core namespace:

    template <class T, class U>
    bool operator <(
            const dds::core::Reference<T>& a,
            const dds::core::Reference<U>& b) OMG_NOEXCEPT
    {
        return a.delegate().get() < b.delegate().get();
    }
    
    template <class T, class U>
    bool operator <=(
            const dds::core::Reference<T>& a,
            const dds::core::Reference<U>& b) OMG_NOEXCEPT
    {
        return a.delegate().get() <= b.delegate().get();
    }
    
    template <class T, class U>
    bool operator >(
            const dds::core::Reference<T>& a,
            const dds::core::Reference<U>& b) OMG_NOEXCEPT
    {
        return a.delegate().get() > b.delegate().get();
    }
    
    template <class T, class U>
    bool operator >=(
            const dds::core::Reference<T>& a,
            const dds::core::Reference<U>& b) OMG_NOEXCEPT
    {
        return a.delegate().get() >= b.delegate().get();
    }
    
  • Reported: DDS-PSM-Cxx 1.0b2 — Fri, 5 Jan 2018 18:24 GMT
  • Updated: Sun, 30 Sep 2018 23:27 GMT