You do not include libraries. You include headers.
Headers are used by the compiler. They contain the declarations for
the functions you wish to use so the compiler knows how to generate
the code to invoke those functions. (Consider the possible need to
convert an argument from int to double as in pow(2,3) or the ability
to specify default values for omitted arguments.) If you call a
function for which there is no declaration in scope, you should
receive a diagnostic.
Libraries are used by the linker. When you code a call to a function,
the compiler generates an entry in the object module that references
that function. The linker will then try to find the definition of
that function in one of the libraries it knows to look through.
There is no inherent relationship between a header and a library. It
is possible for the functions declared in a single header to be spread
out across several libraries. It is just as possible for the
functions declared in several headers to be collected into a single
library.
To answer your question, if the reference to distance was resolved by
the linker, you are using the same distance function whether you
include the <iterator> header or not. If it was not resolved, the
linker should have issued a diagnostic and you would need to inform
the linker where it should look for the function.
--
Remove del for email