[#BloombergLP-bslstl-IteratorUtil-insertDistance]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::xref:BloombergLP/bslstl/IteratorUtil.adoc[IteratorUtil]::insertDistance
:relfileprefix: ../../../
:mrdocs:

Return the number of elements to account for when range&hyphen;inserting&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;iteratorutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class t&lowbar;INPUT&lowbar;ITERATOR,
    class t&lowbar;SENTINEL&gt;
static
bsl::iterator&lowbar;traits&lt;t&lowbar;INPUT&lowbar;ITERATOR&gt;::difference&lowbar;type
insertDistance(
    t&lowbar;INPUT&lowbar;ITERATOR const& first,
    t&lowbar;SENTINEL const& last);
----

== Description

Return 0 if the (template parameter) type `t&lowbar;INPUT&lowbar;ITERATOR` is limited to the standard input&hyphen;iterator category, otherwise return the number of elements reachable from the specified `first` to (but not including) the specified `last`&period; This function has a constant&hyphen;time complexity if the iterator category of `t&lowbar;INPUT&lowbar;ITERATOR` is strictly a standard input iterator, or is a random access iterator, otherwise it is linear in the length of the range `&lsqb;first &period;&period; last)&rsqb;`&period; The behavior is undefined unless `last` is reachable from `first`&period;

== Return Value

the number of elements in `&lsqb;first &period;&period; last)&rsqb;`, or 0 if distance cannot be calculated for the iterator category

== Parameters

[cols="1,4"]
|===
| Name| Description
| *first*
| beginning of the half&hyphen;open range
| *last*
| end of the half&hyphen;open range
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
