]>
Commit | Line | Data |
---|---|---|
0fb0ecc4 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/meta/convertible.h | |
3 | // Purpose: Test if types are convertible | |
4 | // Author: Arne Steinarson | |
5 | // Created: 2008-01-10 | |
0fb0ecc4 VZ |
6 | // Copyright: (c) 2008 Arne Steinarson |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
4f927337 VS |
10 | #ifndef _WX_META_CONVERTIBLE_H_ |
11 | #define _WX_META_CONVERTIBLE_H_ | |
0fb0ecc4 | 12 | |
0503f19c VZ |
13 | // |
14 | // Introduce an extra class to make this header compilable with g++3.2 | |
15 | // | |
16 | template <class D, class B> | |
17 | struct wxConvertibleTo_SizeHelper | |
18 | { | |
03647350 VZ |
19 | static char Match(B* pb); |
20 | static int Match(...); | |
0503f19c VZ |
21 | }; |
22 | ||
0fb0ecc4 VZ |
23 | // Helper to decide if an object of type D is convertible to type B (the test |
24 | // succeeds in particular when D derives from B) | |
25 | template <class D, class B> | |
26 | struct wxConvertibleTo | |
27 | { | |
03647350 VZ |
28 | enum |
29 | { | |
30 | value = | |
31 | sizeof(wxConvertibleTo_SizeHelper<D,B>::Match(static_cast<D*>(NULL))) | |
32 | == | |
33 | sizeof(char) | |
34 | }; | |
0fb0ecc4 VZ |
35 | }; |
36 | ||
4f927337 | 37 | #endif // _WX_META_CONVERTIBLE_H_ |
0fb0ecc4 | 38 |