Templates and VC++

VC++ does not support templates to be declared and defined in two different files.
Does anyone have any workaround?
All I've managed to find was defining a main template function in the .cpp and defining separately all non-template instances of the function. This allows me not to repeat code, but it's tedious as hell:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//.h
//For example, for a copyString() function:
wchar_t *copyWString(wchar_t *str,ulong len=0);
wchar_t *copyWString(char *str,ulong len=0);
char *copyString(wchar_t *str,ulong len=0);
char *copyString(char *str,ulong len=0);

//.cpp
template<typename dst,typename src>
dst *copyString_template(src *str,ulong len){
    ...
}

wchar_t *copyWString(wchar_t *str,ulong len){
    return copyString_template<wchar_t,wchar_t>(str,len);
}

wchar_t *copyWString(char *str,ulong len){
    return copyString_template<wchar_t,char>(str,len);
}

char *copyString(wchar_t *str,ulong len){
    return copyString_template<char,wchar_t>(str,len);
}

char *copyString(char *str,ulong len){
    return copyString_template<char,char>(str,len);
}
Topic archived. No new replies allowed.