// Class template member functions defined outside of the // class template definition need a template function // declaration that matches the template parameter list. // An instance of each template function is instantiated // when the class template is instantiated and that member // function is invoked somewhere in code. // The template parameter list is usually found on a // separate line from the template function due to the // lengths of function parameter lists. // There is no change in behavior, just readability. template void Pair::set_first(Thing ©me) { first_ = copyme; } template void Pair::set_second(Thing ©me) { second_ = copyme; } template void Pair::Swap() { Thing tmp = first_; first_ = second_; second_ = tmp; } // Nonmember function for ostream output -- individual // template parameters can take any name, but usually we // choose to be consistent. T chosen here instead of Thing // for brevity and for fitting onto lecture slides. template ostream &operator<<(ostream &out, const Pair &p) { return out << "Pair(" << p.get_first() << ", " << p.get_second() << ")"; }