fix bug: use T const& instead of T
fix for printing arrays