Avoid always define an external friend function to streamlize an object in the c++ style by using template.