## 22.6 Setting Behavior Using Template Arguments (cont.)

- The comparator is an attribute

>     template<typename T, typename CMP>
>     void OrderedCollection<T, CMP>::insert(T value)
>     {
>        iterator ptr = begin();
>        while (ptr != end())
>        {
>           if (comparator(value, *ptr))
>           {
>              // Found place to insert
>              data.insert(ptr, value);
>              return;
>           }
>           ++ptr;
>        }
>        // Insert at end
>        data.insert(ptr, value);
>     }

prev |top |next