Skip to content

Commit

Permalink
remove (basically default) copy constructors / assignment because it …
Browse files Browse the repository at this point in the history
…violates rule of five.

Also remove unnecessary colons (;).
  • Loading branch information
KerstinKeller committed Jan 12, 2024
1 parent b1de3b3 commit f62c114
Showing 1 changed file with 35 additions and 50 deletions.
85 changes: 35 additions & 50 deletions ecal/core/src/util/ecal_expmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,37 +66,30 @@ namespace eCAL
friend class const_iterator;

public:
iterator(const iterator& i)
: it(i.it)
{};
iterator(const typename key_to_value_type::iterator _it)
: it(_it)
{};
~iterator() = default;
iterator& operator=(const iterator& i)
{
it = i.it;
return *this;
};
{}

iterator& operator++()
{
it++;
return *this;
}; //prefix increment
} //prefix increment

iterator& operator--()
{
it--;
return *this;
}; //prefix decrement
//reference operator*() const
} //prefix decrement

std::pair<Key, T> operator*() const
{
return std::make_pair(it->first, it->second.first);
};
}

//friend void swap(iterator& lhs, iterator& rhs); //C++11 I think
bool operator==(const iterator& rhs) const { return it == rhs.it; };
bool operator!=(const iterator& rhs) const { return it != rhs.it; };

bool operator==(const iterator& rhs) const { return it == rhs.it; }
bool operator!=(const iterator& rhs) const { return it != rhs.it; }

private:
typename key_to_value_type::iterator it;
Expand All @@ -105,43 +98,35 @@ namespace eCAL
class const_iterator : public std::iterator<std::bidirectional_iterator_tag, const std::pair<Key, T>>
{
public:
const_iterator(const const_iterator& i)
: it(i.it)
{};

const_iterator(const iterator& other)
: it(other.it)
{
}
{}

const_iterator(const typename key_to_value_type::const_iterator _it)
: it(_it)
{};
~const_iterator() = default;
const_iterator& operator=(const const_iterator& i)
{
it = i.it;
return *this;
};
{}

const_iterator& operator++()
{
it++;
return *this;
}; //prefix increment
} //prefix increment

const_iterator& operator--()
{
it--;
return *this;
}; //prefix decrement
//reference operator*() const
} //prefix decrement
//reference operator*() const

const std::pair<Key, T> operator*() const
{
return std::make_pair(it->first, it->second.first);
};
}

//friend void swap(iterator& lhs, iterator& rhs); //C++11 I think
bool operator==(const const_iterator& rhs) const { return it == rhs.it; };
bool operator!=(const const_iterator& rhs) const { return it != rhs.it; };

bool operator==(const const_iterator& rhs) const { return it == rhs.it; }
bool operator!=(const const_iterator& rhs) const { return it != rhs.it; }

private:
typename key_to_value_type::const_iterator it;
Expand All @@ -161,22 +146,22 @@ namespace eCAL
iterator begin() noexcept
{
return iterator(_key_to_value.begin());
};
}

iterator end() noexcept
{
return iterator(_key_to_value.end());
};
}

const_iterator begin() const noexcept
{
return const_iterator(_key_to_value.begin());
};
}

const_iterator end() const noexcept
{
return const_iterator(_key_to_value.end());
};
}

// Const begin and end functions
const_iterator cbegin() const noexcept {
Expand All @@ -191,12 +176,12 @@ namespace eCAL
bool empty() const noexcept
{
return _key_to_value.empty();
};
}

size_type size() const noexcept
{
return _key_to_value.size();
};
}

size_type max_size() const noexcept
{
Expand Down Expand Up @@ -234,25 +219,25 @@ namespace eCAL
mapped_type& at(const key_type& k)
{
return _key_to_value.at(k).first;
};
}

const mapped_type& at(const key_type& k) const
{
return _key_to_value.at(k).first;
};
}

// Modifiers
std::pair<iterator, bool> insert(const value_type& val)
{
auto result = insert(val.first, val.second);
return std::make_pair(iterator(result.first), result.second);
};
}

// Operations
iterator find(const key_type& k)
{
return iterator(_key_to_value.find(k));
};
}

// Purge the timed out elements from the cache
void remove_deprecated(std::list<Key>* key_erased = nullptr) //-V826
Expand All @@ -269,7 +254,7 @@ namespace eCAL
_key_to_value.erase(it->second); // erase the element from the map
it = _key_tracker.erase(it); // erase the element from the list
}
};
}

// Remove specific element from the cache
bool erase(const Key& k)
Expand All @@ -282,7 +267,7 @@ namespace eCAL
return true;
}
return false;
};
}

// Remove all elements from the cache
void clear()
Expand All @@ -296,7 +281,7 @@ namespace eCAL
_key_to_value.erase(it->second); // erase the element from the map
it = _key_tracker.erase(it); // erase the element from the list
}
};
}

private:

Expand Down

0 comments on commit f62c114

Please sign in to comment.