This is not a hack, but a shot in the leg. It's like a #define private public . It seems to be compiled and maybe even works, but nothing good will come of it.
Some people even take the view that it’s enough to write this:
/// \bief Функция /// \param[in] t Аргумент /// \warning Допускаются только целочисленные аргументы template <class T> void foo(T t) { }
And that will be enough.
But if you answer your question, you can hide enable_if in the function body:
template <typename T> void foo(T t) { typedef typename std::enable_if<std::is_integral<T>::value>::type Dummy; }
PS: However, if a person has firmly set himself the goal of passing you a double to the function, nothing will stop him:
#include <type_traits> namespace std{ template<> struct is_integral<double>{ static const bool value = true; }; } template <typename T> void foo(T t) { typedef typename std::enable_if<std::is_integral<T>::value>::type Dummy; } int main() { foo(3.14); }
So I recommend you not to worry too much about the "hacks." As long as there is a preprocessor and specialization of templates, you will not be able to protect 100%