I'm writing some code to translate a C++ type to an appropriate type for a SQL DB. I want to identify the type, and then depending on what it is, produce the appropriate SQL code. I'm not sure exactly what can be done in this regard by using RTTI, auto, or decltype. I have some ideas but I'm not sure if they're workable.
For instance (I know the following may not be valid C++, I'm just trying to get the idea across):
if (decltype(some_var) == int) { do_stuff(); }
or
if (decltype(some_var) == decltype(1) { do_stuff(); }
or
switch(decltype(some_var)) {
case int:
do_int_stuff();
break;
case string;
do_string_stuff();
break;
case bool;
do_bool_stuff();
break;
}
or
string get_func_y(int var) {
...
return my_string;
}
string get_func_y(string var) {
...
return my_string;
}
string get_func_y(bool var) {
...
return my_string;
}
...
string SQL = get_func_y(some_var);
Any of this look like it would work, or does anyone have advice on how to go about this? Thanks ahead of time for any input you may have.