How to let user specify float size in data structure?

I'm writing a library to do a math calculation. For my purposes I want to use 32 bit floats, but I can imagine other users wanting to use other sized types. Is the best way to do this to use templates? Can I enforce that the user must have the type be some sort of float?

I'm thinking of using a structure like this:

1
2
3
4
5
6
7

template<typename T = float>
struct Vertex {
    T x;
    T y;
    T z;
};
Registered users can post here. Sign in or register to post.