как победить sprintf ?
решил таки задачку более менее приемлемым способом:
- использование своей функции (меняем поиском/заменой) + несколько темплейтов
теперь компилятор ругается, если в список (который раньше был троеточием) попадает тип, что я не указал.
template<class T> void check_t(T) { wrong type!!!; } // здесь ругается компайлер
template<> inline void check_t(const char*) {}
template<> inline void check_t(char*) {}
template<> inline void check_t(int) {}
template<> inline void check_t(long) {}
template<> inline void check_t(unsigned long) {}
template<> inline void check_t(unsigned long long) {}
template<> inline void check_t(unsigned) {}
template<> inline void check_t(double) {}
template<> inline void check_t(char) {}
template<> inline void check_t(unsigned char) {}
template<class T>
void sprintf_my(char* buf, size_t size, const char* format, T t)
{
check_t(t);
sprintf_s(buf, size, format, t);
}
..... до шести аргументов бывает .....
template<class T, class T2, class T3, class T4, class T5, class T6>
void sprintf_my(char* buf, size_t size, const char* format, T t, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
{
check_t(t);
check_t(t2);
check_t(t3);
check_t(t4);
check_t(t5);
check_t(t6);
sprintf_s(buf, size, format, t, t2, t3, t4, t5, t6);
}