removed libtool from pre-build process
[ardour.git] / libs / sigc++2 / sigc++ / type_traits.h
1 /*
2  * Copyright 2002, The libsigc++ Development Team
3  *
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.
8  *
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.
13  *
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
17  *
18  */
19 #ifndef _SIGC_TYPE_TRAIT_H_
20 #define _SIGC_TYPE_TRAIT_H_
21
22 #include <sigc++/reference_wrapper.h>
23
24 namespace sigc {
25
26 template <class T_type>
27 struct type_trait
28 {
29   typedef T_type  type;
30   typedef T_type& pass;
31   typedef const T_type& take;
32   typedef T_type* pointer;
33 };
34
35 template <class T_type, int N>
36 struct type_trait<T_type[N]>
37 {
38   typedef T_type*  type;
39   typedef T_type*& pass;
40   typedef const T_type*& take;
41   typedef T_type** pointer;
42 };
43
44 template <class T_type>
45 struct type_trait<T_type&>
46 {
47   typedef T_type  type;
48   typedef T_type& pass;
49   typedef T_type& take;
50   typedef T_type* pointer;
51 };
52
53 template <class T_type>
54 struct type_trait<const T_type&>
55 {
56   typedef const T_type  type;
57   typedef const T_type& pass;
58   typedef const T_type& take;
59   typedef const T_type* pointer;
60 };
61
62 template <class T_type>
63 struct type_trait<reference_wrapper<T_type> >
64 {
65   typedef T_type  type;
66   typedef T_type& pass;
67   typedef T_type& take;
68   typedef T_type* pointer;
69 };
70
71 template <class T_type>
72 struct type_trait<const_reference_wrapper<T_type> >
73 {
74   typedef T_type  type;
75   typedef T_type& pass;
76   typedef const T_type& take;
77   typedef T_type* pointer;
78 };
79
80 template<>
81 struct type_trait<void>
82 {
83   typedef void  type;
84   typedef void  pass;
85   typedef void  take;
86   typedef void* pointer;
87 };
88
89
90 /** From Esa Pulkkin:
91  * Compile-time determination of base-class relationship in C++
92  * (adapted to match the syntax of boost's type_traits library).
93  */
94 template <class T_base, class T_derived>
95 struct is_base_and_derived
96 {
97 private:
98   struct big {
99     char memory[64];
100   };
101
102   struct test {
103     static big  is_base_class_(...);
104     static char is_base_class_(typename type_trait<T_base>::pointer);
105   };
106
107 public:
108   static const bool value =
109     sizeof(test::is_base_class_((typename type_trait<T_derived>::pointer)0)) ==
110     sizeof(char);
111 };
112
113 template <class T_base>
114 struct is_base_and_derived<T_base, T_base>
115 {
116   static const bool value = true;
117 };
118
119 } /* namespace sigc */
120
121 #endif /* _SIGC_TYPE_TRAIT_H_ */