I have the following piece of code:
template<typename T, typename... args>
void func(const my_type<T, args...>& set, std::ofstream t_print, std::ofstream args_print) {
t_print << set.get_t() << std::endl;
if (sizeof...(args) > 0)
data << set.get_args() << std::endl;
}
}
The evaluation of the if condition is deferred to run time, and the compiler generates code for the body of the if. My question is if there is a way to make that the compiler does not generate code in case of sizeof...(args) == 0, without the use of the template specialization technique. Is there any workaround in modern C++?
Aucun commentaire:
Enregistrer un commentaire