M
Michael Le Barbier Grünewald
Dear Group,
I would like to write a new, type-safe, interface to existing code. I wonder if it is possible to define a template and specialisation of this template such that use of the non-specialised template triggers an error at compile time (good) or link time (worse).
I figured out I need this to solve my interface problem, it may worth to describe it in greater details, maybe you habe an even better solution!
Existing-code is a printing facility, built around an enum, like
enum STYLE { DOUBLE1, DOUBLE2, STRING1, STRING2 }
and overloaded functions
void print(STYLE, double);
void print(STYLE, const& string);
The first parameter of the print function is used to convey styling information and, as the name suggests, DOUBLE1 and DOUBLE2 are only soundly used in conjunction with a double while STRING1 and STRING2 should be used with strings (std::string).
Thank you for your insight!
Michael
I would like to write a new, type-safe, interface to existing code. I wonder if it is possible to define a template and specialisation of this template such that use of the non-specialised template triggers an error at compile time (good) or link time (worse).
I figured out I need this to solve my interface problem, it may worth to describe it in greater details, maybe you habe an even better solution!
Existing-code is a printing facility, built around an enum, like
enum STYLE { DOUBLE1, DOUBLE2, STRING1, STRING2 }
and overloaded functions
void print(STYLE, double);
void print(STYLE, const& string);
The first parameter of the print function is used to convey styling information and, as the name suggests, DOUBLE1 and DOUBLE2 are only soundly used in conjunction with a double while STRING1 and STRING2 should be used with strings (std::string).
Thank you for your insight!
Michael