Skip to content

Instantly share code, notes, and snippets.

@maxtruxa
Created May 19, 2015 14:26
Show Gist options
  • Save maxtruxa/2bd4aa6b0ddc8d204cc5 to your computer and use it in GitHub Desktop.
Save maxtruxa/2bd4aa6b0ddc8d204cc5 to your computer and use it in GitHub Desktop.
template<typename TMapIterator>
class key_iterator : public TMapIterator
{
public:
typedef typename TMapIterator::value_type::first_type key_type;
key_iterator() : TMapIterator() { }
key_iterator(TMapIterator iter) : TMapIterator(iter) { }
key_type* operator->()
{
return &this->TMapIterator::operator->()->first;
}
key_type& operator*()
{
return this->TMapIterator::operator*().first;
}
};
template<typename TMapIterator>
key_iterator<TMapIterator> make_key_iterator(TMapIterator iter)
{
return key_iterator<TMapIterator>(iter);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment