I don't see the point in writing your own template function to do this, that is what std::pow does - no need to reinvent the wheel.
So osgwsy's solution is the best one.
Personally, I explicitly specify the zero after the decimal point for FP numbers - as in 3.0 but not 3 or 3. (no decimal point, or nothing after decimal point) Doing means the number will be a double by default and is easier to read IMO.
Other than as an exercise, it's not usually a good idea to re-invent the wheel. I don't remember the context, but I saw some other example recently where a library function had been re-written by someone.
Doing that is fine, as a study task. It can be a good way to learn. But the larger issue is that the library functions are thoroughly tested and well-documented. Their properties, including any limitations, are known.
Once one starts writing one's own versions of any function, then all the testing, debugging, optimising and documenting has to be done all over again. Although I'd do that with my own code, if the code came from some other source I'd go for the library version every time.