Reputation: 209
I have this code:
template <typename Iter>
class map_iterator : public std::iterator<std::bidirectional_iterator_tag, typename Iter::value_type::second_type> {
public:
map_iterator() {}
map_iterator(Iter j) : i(j) {}
map_iterator& operator++() { ++i; return *this; }
map_iterator operator++(int) { auto tmp = *this; ++(*this); return tmp; }
map_iterator& operator--() { --i; return *this; }
map_iterator operator--(int) { auto tmp = *this; --(*this); return tmp; }
bool operator==(map_iterator j) const { return i == j.i; }
bool operator!=(map_iterator j) const { return !(*this == j); }
reference operator*() { return i->second; }
pointer operator->() { return &i->second; }
protected:
Iter i;
};
template <typename Iter>
inline map_iterator<Iter> make_map_iterator(Iter j) { return map_iterator<Iter>(j); }
using route_departure_container = std::map<packed_time, route_departure_o>;
template <typename Iter>
using route_departure_const_iterator = map_iterator;
route_departure_const_iterator departure_at(const std::pair<key, const platform_route_o&>& pr, packed_time tm);
I have map using route_departure_container = std::map<packed_time, route_departure_o>;
and I want to iterate through this map in a way that the iterator would reference only on the value and not the pair<key, value>.
The problem I have is in the last line route_departure_const_iterator departure_at(const std::pair<key, const platform_route_o&>& pr, packed_time tm);
where route_departure_const_iterator
is underlined with red and it says: argument list for alias template "route_departure_const_iterator" is missing.
I tried to insert template <typename Iter>
above this line but it did not help. What should I do?
Upvotes: 0
Views: 65
Reputation: 67380
The same way you wrote the above declaration:
template <typename Iter>
inline map_iterator<Iter> make_map_iterator(Iter j) { return map_iterator<Iter>(j); }
You also need to write your problematic declaration:
template <typename Iter>
route_departure_const_iterator<Iter> departure_at(const std::pair<key, const platform_route_o&>& pr, packed_time tm);
Because the way you defined route_departure_const_iterator
is just a plain, non-const alias to map_iterator
, so you use it the same.
Upvotes: 1