[#BloombergLP-bslstl-IteratorUtil_LegacyInsertDistance-03] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::IteratorUtil_LegacyInsertDistance :relfileprefix: ../../ :mrdocs: This supporting utility type is used for type‐based dispatch as part of the implementation of the similarly structured functions `insertDistance` and `canCalculateInsertDistance` from `IteratorUtil`. Selection between the primary template and secondary (much simpler) one is performed based on the defaulted third parameter that checks if the (template parameter) type `t_SENTINEL` is convertible to the (template parameter) type `t_INPUT_ITERATOR`. When the primary template is selected, the decision to delegate distance calculation to `bsl::distance` is performed using tag dispatch. == Synopsis Declared in `<bslstl_iteratorutil.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class t_INPUT_ITERATOR, class t_SENTINEL, bool t_MATCHING_SENTINEL = bsl::is_convertible<t_SENTINEL, t_INPUT_ITERATOR>::value> struct IteratorUtil_LegacyInsertDistance; ---- == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslstl/IteratorUtil_LegacyInsertDistance-03/canCalculate.adoc[`canCalculate`] | Return `true` if the (template parameter) type `t_INPUT_ITERATOR` has a forward iterator category and the (template parameter) type `t_SENTINEL` is convertible to `t_INPUT_ITERATOR`. | xref:BloombergLP/bslstl/IteratorUtil_LegacyInsertDistance-03/insertDistance.adoc[`insertDistance`] | Return the number of elements in the range `[first, last)]` if the (template parameter) type `t_SENTINEL` is convertible to the (template parameter) type `t_INPUT_ITERATOR` and `t_INPUT_ITERATOR` has a forward iterator category; otherwise return 0. |=== == Specializations [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslstl/IteratorUtil_LegacyInsertDistance-0c.adoc[`IteratorUtil_LegacyInsertDistance<t_INPUT_ITERATOR, t_SENTINEL, false>`] | This partial specialization handles the case where the sentinel type is not convertible to the iterator type and thus we do not support distance calculation. Note that this choice primarily applies on legacy platforms or when iterators do not properly model the modern iterator concepts. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#