2 * Copyright 2002, The libsigc++ Development Team
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef _SIGC_TYPE_TRAIT_H_
20 #define _SIGC_TYPE_TRAIT_H_
22 #include <sigc++/reference_wrapper.h>
26 template <class T_type>
31 typedef const T_type& take;
32 typedef T_type* pointer;
35 template <class T_type, int N>
36 struct type_trait<T_type[N]>
39 typedef T_type*& pass;
40 typedef const T_type*& take;
41 typedef T_type** pointer;
44 template <class T_type>
45 struct type_trait<T_type&>
50 typedef T_type* pointer;
53 template <class T_type>
54 struct type_trait<const T_type&>
56 typedef const T_type type;
57 typedef const T_type& pass;
58 typedef const T_type& take;
59 typedef const T_type* pointer;
62 template <class T_type>
63 struct type_trait<reference_wrapper<T_type> >
68 typedef T_type* pointer;
71 template <class T_type>
72 struct type_trait<const_reference_wrapper<T_type> >
76 typedef const T_type& take;
77 typedef T_type* pointer;
81 struct type_trait<void>
86 typedef void* pointer;
91 * Compile-time determination of base-class relationship in C++
92 * (adapted to match the syntax of boost's type_traits library).
94 template <class T_base, class T_derived>
95 struct is_base_and_derived
103 static big is_base_class_(...);
104 static char is_base_class_(typename type_trait<T_base>::pointer);
108 static const bool value =
109 sizeof(test::is_base_class_((typename type_trait<T_derived>::pointer)0)) ==
113 template <class T_base>
114 struct is_base_and_derived<T_base, T_base>
116 static const bool value = true;
119 } /* namespace sigc */
121 #endif /* _SIGC_TYPE_TRAIT_H_ */