I have this code, which fills my row structure with string data for each column.
struct row_t
{
row_t()
{};
template<typename ...T>
row_t(const T& ...var)
{
append(var...);
}
template<typename T, typename ...Types>
void append(const T &var1, const Types& ...var2)
{
// here should be some kind of check, that number of arguments == COLUMN_COUNT
data.append_copy(var1);
append(var2...);
}
template<typename T>
void append(const T &var1)
{
data.append_copy(var1);
}
array_local_t<sstring_t, COLUMN_COUNT> data; // my implementation of arrays
};
and I can call is like this:
row_t tmp_row(a,b,c,d);
//with a, b, c, d being my sstring_t types
Now, as you might noticed, my data array is of type sstring_t. So If i tried to call this with a,b,c,d being int, I would not be able to compile the code -> I don't need or want the template functions to be of Typename T, but only sstring_t, because that is the only thing that makes sense in my case (so I dont want to change data array to type T and call it a day). I was only able to write the code like this. Can you help me to convert it to specific type only(sstring_t) using C++11 max?
Aucun commentaire:
Enregistrer un commentaire