template build error, simliar with chromium callback module

I am reading chromium source code about callback module , and I tried to write a simple example as below, but the code can't compile successfully , could you help see it ? thanks a lot , build env : vs2008


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
29
30
31
32
33
34
35
// callback.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

template <typename R, typename A1, typename A2> struct T_Funct;
template <typename R, typename A1, typename A2> struct T_Funct<R (__stdcall *)(A1,A2), A1, A2>{
	typedef R (Run)(A1,A2);
	R (__stdcall *function_)(A1, A2);
	explicit T_Funct(R(__stdcall *function)(A1,A2), A1 a1, A2 a2):function_(function),a1_(a1),a2_(a2){}
	R operator()(){
		return function_();
	}
};

int show_int(int , int ){
	return printf("print_int is invoked...\n");
}






int _tmain(int argc, _TCHAR* argv[])
{
	typedef int (*p_fun_int)(int, int );
	p_fun_int fun_int;
	fun_int = show_int;
	
	T_Funct<int , int , int > t_funct(fun_int, 1,2);

	return 0;
}



and build output is below:

1>------ Build started: Project: callback, Configuration: Debug Win32 ------
1>Compiling...
1>callback.cpp
1>e:\code\template\callback\callback\callback.cpp(31) : error C2079: 't_funct' uses undefined struct 'T_Funct<R,A1,A2>'
1> with
1> [
1> R=int,
1> A1=int,
1> A2=int
1> ]
1>e:\code\template\callback\callback\callback.cpp(31) : error C2078: too many initializers
1>Build log was saved at "file://e:\code\template\callback\callback\Debug\BuildLog.htm"
1>callback - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Topic archived. No new replies allowed.