Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
This is done for several reasons.
First, so that the template parameter can be accessed in other templates. Here, you gave an example with _Сontainer
in some iterator. You can imagine that there is some kind of algorithm (function) that takes an iterator and it will need to somehow use the container type (or create a temporary variable, or set the return value type, or somehow check that the container type has some properties).
In this case, the algorithm should receive this one back_insert_iterator
and a dozen other iterators. Therefore, it is impossible to take out the container type into a template parameter and specify it in the iterator type in the function parameter. You look in the source code for this very "_Container" - it will become clear how it is used.
Secondly, sometimes it is done for convenience. For in these templates, the parameters themselves can be hellishly piled up with templates.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question