This is a generic question about templating, I am using advance as an example. Assume there are reasons I can't use ADL or hidden friends here.
The definition of std::advance
is:
template< class InputIt, class Distance >
constexpr void advance( InputIt& it, Distance n );
For the sake of argument, say I have a container H, with iterators which for some reason I want to overload std::advance
for:
template <typename T, class Allocator=std::allocator<T>>
class H
{
// etc
class iterator;
};
How does one design an advance overload to match that iterator, and have C++ correctly select the overload when calling advance on H's iterator class? The code below does not work because only H is specified in the templating, not the iterator itself:
template< template <typename, class> class container, class T, class Allocator, class Distance >
constexpr void advance( container<T, Allocator>::iterator& it, Distance n );
I can't quite work out how to specify the iterator specifically in the template line.