D
Damian
Hi there,
I would like to restrict a template parameter to a template functioned
to either a signed or unsigned type, but not both.
For example, the following templated function should ideally only be
instantiated with unsigned types.
template <typename unsigned T>
inline T id(T *i) {
return i;
}
void foo() {
(void)id<int>(k); // should return an error.
(void)id<unsigned int>(k); // should be fine.
}
Does anyone know how I can achieve this?
Thanks!
Best Regards,
Damian Eads
I would like to restrict a template parameter to a template functioned
to either a signed or unsigned type, but not both.
For example, the following templated function should ideally only be
instantiated with unsigned types.
template <typename unsigned T>
inline T id(T *i) {
return i;
}
void foo() {
(void)id<int>(k); // should return an error.
(void)id<unsigned int>(k); // should be fine.
}
Does anyone know how I can achieve this?
Thanks!
Best Regards,
Damian Eads