~brian-sidebotham/wxwidgets-cmake/wxpython-2.9.4

« back to all changes in this revision

Viewing changes to include/wx/meta/convertible.h

  • Committer: Brian Sidebotham
  • Date: 2013-08-03 14:30:08 UTC
  • Revision ID: brian.sidebotham@gmail.com-20130803143008-c7806tkych1tp6fc
Initial import into Bazaar

Show diffs side-by-side

added added

removed removed

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