Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / interprocess / detail / type_traits.hpp
1 //////////////////////////////////////////////////////////////////////////////
2 // (C) Copyright John Maddock 2000.
3 // (C) Copyright Ion Gaztanaga 2005-2012.
4 //
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // See http://www.boost.org/libs/interprocess for documentation.
10 //
11 //////////////////////////////////////////////////////////////////////////////
12
13 #ifndef BOOST_INTERPROCESS_DETAIL_TYPE_TRAITS_HPP
14 #define BOOST_INTERPROCESS_DETAIL_TYPE_TRAITS_HPP
15
16 #if defined(_MSC_VER)
17 #  pragma once
18 #endif
19
20 #include <boost/interprocess/detail/config_begin.hpp>
21
22 namespace boost {
23 namespace interprocess {
24 namespace ipcdetail {
25
26 struct nat{};
27
28 template<class T>
29 struct remove_reference
30 {
31    typedef T type;
32 };
33
34 template<class T>
35 struct remove_reference<T&>
36 {
37    typedef T type;
38 };
39
40 template<class T>
41 struct is_reference
42 {
43    static const bool value = false;
44 };
45
46 template<class T>
47 struct is_reference<T&>
48 {
49    static const bool value = true;
50 };
51
52 template<class T>
53 struct is_pointer
54 {
55    static const bool value = false;
56 };
57
58 template<class T>
59 struct is_pointer<T*>
60 {
61    static const bool value = true;
62 };
63
64 template <typename T>
65 struct add_reference
66 {
67     typedef T& type;
68 };
69
70 template<class T>
71 struct add_reference<T&>
72 {
73     typedef T& type;
74 };
75
76 template<>
77 struct add_reference<void>
78 {
79     typedef nat &type;
80 };
81
82 template<>
83 struct add_reference<const void>
84 {
85     typedef const nat &type;
86 };
87
88 template <class T>
89 struct add_const_reference
90 {  typedef const T &type;   };
91
92 template <class T>
93 struct add_const_reference<T&>
94 {  typedef T& type;   };
95
96 template<class T>
97 struct remove_const
98 {
99    typedef T type;
100 };
101
102 template<class T>
103 struct remove_const<const T>
104 {
105    typedef T type;
106 };
107
108 template<class T>
109 struct remove_volatile
110 {
111    typedef T type;
112 };
113
114 template<class T>
115 struct remove_volatile<volatile T>
116 {
117    typedef T type;
118 };
119
120 template<class T>
121 struct remove_const_volatile
122 {
123    typedef typename remove_const<typename remove_volatile<T>::type>::type type;
124 };
125
126 template <typename T, typename U>
127 struct is_same
128 {
129    typedef char yes_type;
130    struct no_type
131    {
132       char padding[8];
133    };
134
135    template <typename V>
136    static yes_type is_same_tester(V*, V*);
137    static no_type is_same_tester(...);
138
139    static T *t;
140    static U *u;
141
142    static const bool value = sizeof(yes_type) == sizeof(is_same_tester(t,u));
143 };
144
145 template<class T, class U>
146 struct is_cv_same
147 {
148    static const bool value = is_same< typename remove_const_volatile<T>::type
149                                     , typename remove_const_volatile<U>::type >::value;
150 };
151
152 } // namespace ipcdetail
153 }  //namespace interprocess {
154 }  //namespace boost {
155
156 #include <boost/interprocess/detail/config_end.hpp>
157
158 #endif   //#ifndef BOOST_INTERPROCESS_DETAIL_TYPE_TRAITS_HPP