/*simple insertion sort *template void insertionsortvector forint size)++ comparable tmp std::moveap )int jforj pj &tmp aj ]-- aj std::moveaj )aj std::movetmp )figure insertion sort routine stl implementation of insertion sort in the stlinstead of having the sort routines take an array of comparable items as single parameterthe sort routines receive pair of iterators that represent the start and endmarker of range two-parameter sort routine uses just that pair of iterators and presumes that the items can be orderedwhile three-parameter sort routine has function object as third parameter converting the algorithm in figure to use the stl introduces several issues the obvious issues are we must write two-parameter sort and three-parameter sort presumablythe twoparameter sort invokes the three-parameter sortwith lessas the third parameter array access must be converted to iterator access line of the original code requires that we create tmpwhich in the new code will have type object the first issue is the trickiest because the template type parameters ( the generic typesfor the two-parameter sort are both iteratorhoweverobject is not one of the generic type parameters prior to ++ one had to write extra routines to solve this problem as shown in figure ++ introduces decltype which cleanly expresses the intent figure shows the main sorting code that replaces array indexing with use of the iteratorand that replaces calls to operatorwith calls to the lessthan function object observe that once we actually code the insertionsort algorithmevery statement in the original code is replaced with corresponding statement in the new code that makes