cv::Mat to CDenseFeature conversion Factory and vice versa.

I have made a factory which directly converts any cvMat object into any(required) type of CDenseFeatures. 
and  CDenseFeature<float64_t> into the required type of cvMat (any)
I don't understand how this works but it does - maybe a place for a comment? or can someone explain this to me