Skip to content
Snippets Groups Projects
Commit a8773391 authored by Benjamin Cumming's avatar Benjamin Cumming
Browse files

improve STL iterator support in threading code

* use iterator and const_iterator type members instead
of iterator_type and const_iterator_type
* add begin() end() to the thread_enumerable spike storage
to iterator over thread local storage
parent fac70f4a
No related branches found
No related tags found
No related merge requests found
......@@ -69,6 +69,18 @@ private :
threading::enumerable_thread_specific<std::vector<spike_type>>;
local_spike_store_type buffers_;
public :
using iterator = typename local_spike_store_type::iterator;
using const_iterator = typename local_spike_store_type::const_iterator;
// make the container iterable
// we iterate of threads, not individual containers
iterator begin() { return buffers_.begin(); }
iterator end() { return buffers_.begin(); }
const_iterator begin() const { return buffers_.begin(); }
const_iterator end() const { return buffers_.begin(); }
};
} // namespace mc
......
......@@ -19,10 +19,10 @@ namespace threading {
template <typename T>
class enumerable_thread_specific {
std::array<T, 1> data;
using iterator_type = typename std::array<T, 1>::iterator;
using const_iterator_type = typename std::array<T, 1>::const_iterator;
public :
public :
using iterator = typename std::array<T, 1>::iterator;
using const_iterator = typename std::array<T, 1>::const_iterator;
enumerable_thread_specific() = default;
......@@ -39,14 +39,14 @@ class enumerable_thread_specific {
auto size() -> decltype(data.size()) const { return data.size(); }
iterator_type begin() { return data.begin(); }
iterator_type end() { return data.end(); }
iterator begin() { return data.begin(); }
iterator end() { return data.end(); }
const_iterator_type begin() const { return data.begin(); }
const_iterator_type end() const { return data.end(); }
const_iterator begin() const { return data.begin(); }
const_iterator end() const { return data.end(); }
const_iterator_type cbegin() const { return data.cbegin(); }
const_iterator_type cend() const { return data.cend(); }
const_iterator cbegin() const { return data.cbegin(); }
const_iterator cend() const { return data.cend(); }
};
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment