X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Futils.hpp;h=326f0ae746396312e235d105af4a8c4b8fe66011;hb=dc88217e78259cb6b35fbaf6b85ad5aed6a37023;hp=61fb6f6ffbbf9a1d8003a757b1e242e3f1e97f4a;hpb=f053d40c60b9dd38da27d88412dcac3a8404324c;p=lttng-tools.git diff --git a/src/bin/lttng/utils.hpp b/src/bin/lttng/utils.hpp index 61fb6f6ff..326f0ae74 100644 --- a/src/bin/lttng/utils.hpp +++ b/src/bin/lttng/utils.hpp @@ -26,13 +26,19 @@ extern pid_t sessiond_pid; struct cmd_struct; struct session_spec { - enum type { + enum class type { NAME, GLOB_PATTERN, ALL, }; - type type; + explicit session_spec(type spec_type, const char *name_or_pattern = nullptr) noexcept : + type_(spec_type), value(name_or_pattern) + { + } + + /* Disambiguate type enum from the member for buggy g++ versions. */ + type type_; const char *value; }; @@ -41,42 +47,42 @@ struct session_spec { */ class session_list { template - class iterator_template : public std::iterator { + class _iterator : public std::iterator { public: - explicit iterator_template(ContainerType& list, std::size_t k) : _list(list), _index(k) + explicit _iterator(ContainerType& list, std::size_t k) : _list(list), _index(k) { } - iterator_template& operator++() noexcept + _iterator& operator++() noexcept { ++_index; return *this; } - iterator_template& operator--() noexcept + _iterator& operator--() noexcept { --_index; return *this; } - iterator_template& operator++(int) noexcept + _iterator& operator++(int) noexcept { _index++; return *this; } - iterator_template& operator--(int) noexcept + _iterator& operator--(int) noexcept { _index--; return *this; } - bool operator==(iterator_template other) const noexcept + bool operator==(_iterator other) const noexcept { return _index == other._index; } - bool operator!=(iterator_template other) const noexcept + bool operator!=(_iterator other) const noexcept { return !(*this == other); } @@ -91,8 +97,8 @@ class session_list { std::size_t _index; }; - using iterator = iterator_template; - using const_iterator = iterator_template; + using iterator = _iterator; + using const_iterator = _iterator; public: session_list() : _sessions_count(0), _sessions(nullptr)