The code you posted is correct but reading your error shows that the problem does not lie within that line. "warning: friend decleration of operator << declares a non-template function" that gives me the idea that in your class implementation of Set your decleration of the friend function does not match up with its definition. So check out the decleration and if you can't figure it out please post the class definition here.