Title is a little ambiguous.
Lets say I have a template defined as:
template < typename T >
void foo ( int x ) ;
template <>
void foo
You need your remap
trait to simply map from input types to output types, and have your foo
interface function delegate to a foo_implementation
implementation. i.e.:
template
struct remap {
// Default: Output type is the same as input type.
typedef T type;
};
template <>
struct remap {
typedef unsigned char type;
};
template <>
struct remap {
typedef unsigned char type;
};
template
void foo_impl(int x);
template <>
void foo_impl(int x) {
std::cout << "foo_impl(" << x << ") called\n";
}
template
void foo(int x) {
foo_impl::type>(x);
}
See it live at ideone.com.
That said, it might be realistically simpler to define foo_char
, foo_int
and foo_short
and just call the correct one from client code. foo
isn't syntactically much different from foo_X()
.