bug fix: move template function/class impl to header file(g++ limitation).