If it is OK to make the switch at compile time, a simple typedef
would do:
#ifdef USE_DOUBLES
typedef double user_data_t;
#else
typedef float user_data_t;
#endif
Use user_data_t
in your code, and set USE_DOUBLES
if you want doubles
at compile time:
g++ -DUSE_DOUBLES=1 myprogram.cpp