From d83ba9baef029eedf530d272d95487e9c59d4226 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 12 Mar 2024 15:48:09 -0400 Subject: [PATCH] Build fix: missing operator- for iterator on g++7 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The project fails to build on 'g++ (SUSE Linux) 7.5.0' since its STL implementation assumes that operator- is available for random access iterators. The build fails with the following error: event_name.cpp:82:71: required from here /usr/include/c++/7/bits/stl_iterator_base_funcs.h:104:21: error: no match for ‘operator-’ (operand types are ‘lttng::utils::random_access_container_wrapper::_iterator, const char* const>’ and ‘lttng::utils::random_access_container_wrapper::_iterator, const char* const>’) A trivial implementation of that operator is provided and allows the build to succeed. Signed-off-by: Jérémie Galarneau Change-Id: Ib1637e81e5cdc42cd5a142dcee21150ced9fcc55 --- src/common/container-wrapper.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/container-wrapper.hpp b/src/common/container-wrapper.hpp index 20642a8d2..25385fc43 100644 --- a/src/common/container-wrapper.hpp +++ b/src/common/container-wrapper.hpp @@ -60,6 +60,11 @@ class random_access_container_wrapper { return *this; } + ptrdiff_t operator-(const _iterator& other) const + { + return _index - other._index; + } + bool operator==(const _iterator& other) const noexcept { return _index == other._index; -- 2.34.1