ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/deliantra/dclient/testsuite/adt/test_function.h
Revision: 1.1
Committed: Sun Oct 17 08:15:14 2010 UTC (16 years ago) by sf-pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
initial import

File Contents

# User Rev Content
1 sf-pippijn 1.1 #if 1
2     namespace std
3     {
4    
5     template<typename Func>
6     struct function;
7    
8     template<typename R, typename... Args>
9     struct function<R (Args...)>
10     {
11     typedef R function_type (Args...);
12    
13     function_type *func;
14    
15     R operator () (Args...)
16     {
17     return func ();
18     }
19    
20     function &operator = (function_type *func)
21     {
22     this->func = func;
23     return *this;
24     }
25     };
26    
27     }
28     #else
29     #include <functional>
30     #endif
31    
32     struct with_function
33     {
34     std::function<void ()> cb;
35    
36     void operator () () { cb (); }
37     };
38    
39     struct with_virtual
40     {
41     struct interface
42     {
43     virtual void cb () = 0;
44     };
45    
46     interface *iface;
47    
48     void operator () () { iface->cb (); }
49     };
50    
51     extern with_function wf;
52     extern with_virtual wv;