diff --git a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp index 616bdfffe..cc423795f 100644 --- a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp +++ b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp @@ -31,7 +31,7 @@ class UniquePublisherId { auto operator=(UniquePublisherId&& rhs) noexcept -> UniquePublisherId&; ~UniquePublisherId(); - auto bytes() -> iox::optional&; + auto bytes() -> const iox::optional&; private: template @@ -56,7 +56,7 @@ class UniqueSubscriberId { auto operator=(UniqueSubscriberId&& rhs) noexcept -> UniqueSubscriberId&; ~UniqueSubscriberId(); - auto bytes() -> iox::optional&; + auto bytes() -> const iox::optional&; private: template @@ -80,7 +80,7 @@ class UniqueNotifierId { auto operator=(UniqueNotifierId&& rhs) noexcept -> UniqueNotifierId&; ~UniqueNotifierId(); - auto bytes() -> iox::optional&; + auto bytes() -> const iox::optional&; private: template @@ -104,7 +104,7 @@ class UniqueListenerId { auto operator=(UniqueListenerId&& rhs) noexcept -> UniqueListenerId&; ~UniqueListenerId(); - auto bytes() -> iox::optional&; + auto bytes() -> const iox::optional&; private: template diff --git a/iceoryx2-ffi/cxx/src/unique_port_id.cpp b/iceoryx2-ffi/cxx/src/unique_port_id.cpp index cb354703e..07b07409a 100644 --- a/iceoryx2-ffi/cxx/src/unique_port_id.cpp +++ b/iceoryx2-ffi/cxx/src/unique_port_id.cpp @@ -43,7 +43,7 @@ UniquePublisherId::UniquePublisherId(iox2_unique_publisher_id_h handle) : m_handle { handle } { } -auto UniquePublisherId::bytes() -> iox::optional& { +auto UniquePublisherId::bytes() -> const iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_publisher_id_value(m_handle, bytes.data(), bytes.size()); @@ -90,7 +90,7 @@ UniqueSubscriberId::UniqueSubscriberId(iox2_unique_subscriber_id_h handle) : m_handle { handle } { } -auto UniqueSubscriberId::bytes() -> iox::optional& { +auto UniqueSubscriberId::bytes() -> const iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_subscriber_id_value(m_handle, bytes.data(), bytes.size()); @@ -136,7 +136,7 @@ UniqueNotifierId::UniqueNotifierId(iox2_unique_notifier_id_h handle) : m_handle { handle } { } -auto UniqueNotifierId::bytes() -> iox::optional& { +auto UniqueNotifierId::bytes() -> const iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_notifier_id_value(m_handle, bytes.data(), bytes.size()); @@ -182,7 +182,7 @@ UniqueListenerId::UniqueListenerId(iox2_unique_listener_id_h handle) : m_handle { handle } { } -auto UniqueListenerId::bytes() -> iox::optional& { +auto UniqueListenerId::bytes() -> const iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_listener_id_value(m_handle, bytes.data(), bytes.size());