Build fix: g++ 4.8 incorrectly disambiguates enum and member
[lttng-tools.git] / src / bin / lttng / utils.hpp
index 4fa15c38d2f26a689e93d34c8896d7e1b8fb8bdc..262775d1d6bf0513e75f83c1ff0a939c68266b7d 100644 (file)
@@ -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,44 @@ struct session_spec {
  */
 class session_list {
        template <typename ContainerType, typename DereferenceReturnType>
-       class iterator_template : public std::iterator<std::random_access_iterator_tag, std::size_t> {
+       class _iterator
+               : public std::iterator<std::random_access_iterator_tag, std::size_t> {
        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 +99,8 @@ class session_list {
                std::size_t _index;
        };
 
-       using iterator = iterator_template<session_list, lttng_session>;
-       using const_iterator = iterator_template<const session_list, const lttng_session>;
+       using iterator = _iterator<session_list, lttng_session>;
+       using const_iterator = _iterator<const session_list, const lttng_session>;
 
 public:
        session_list() : _sessions_count(0), _sessions(nullptr)
@@ -156,7 +164,7 @@ public:
 private:
        std::size_t _sessions_count;
        std::unique_ptr<lttng_session,
-                       lttng::details::create_unique_class<lttng_session, lttng::free>>
+                       lttng::memory::create_deleter_class<lttng_session, lttng::free>::deleter>
                _sessions;
 };
 
This page took 0.024136 seconds and 4 git commands to generate.