X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcontainer-wrapper.hpp;h=25385fc43837961ec4301dd9f7254f0b89ccc3b6;hb=HEAD;hp=c2c59f89da06f07595d5c7cd262dfbc3fcbdde35;hpb=58561706ca99e043a4687a776dc781bdf7e78e07;p=lttng-tools.git diff --git a/src/common/container-wrapper.hpp b/src/common/container-wrapper.hpp index c2c59f89d..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; @@ -117,6 +122,11 @@ public: return ContainerOperations::size(_container); } + bool empty() const + { + return size() == 0; + } + typename std::conditional::value, ElementType, ElementType&>::type operator[](std::size_t index) { @@ -130,7 +140,7 @@ public: * * For more information, see Item 3 of Effective C++. */ - const auto& const_this = static_cast(*this); + const auto& const_this = static_cast(*this); /* NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) */ return const_cast::value, @@ -144,7 +154,7 @@ public: operator[](std::size_t index) const { if (index >= ContainerOperations::size(_container)) { - LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format( + throw std::invalid_argument(lttng::format( "Out of bound access through random_access_container_wrapper: index={}, size={}", index, size()));