I have many overloaded functions that work with certain data types, such as int, double and strings. Most of these functions perform the same action where only a specific set of data types is allowed. This means that I cannot create a simple general template function, since I will lose type safety (and there may be a runtime problem for checking inside the function).
Is it possible to create a βhalf-copied function like compile time"? If so, how? If not, is this something that will appear in C ++ 0x?
Idea (invalid);
template <typename T, restrict: int, std::string > void foo(T bar); ... foo((int)0);
Note. I understand that I can create a class with overloaded constructors and assignment operators and pass a variable to this class instead of a function.
source share