solve the issue on C++ frined template function