1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2005-2012.
4 // (C) Copyright Gennaro Prota 2003 - 2004.
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 //
10 // See http://www.boost.org/libs/interprocess for documentation.
11 //
12 //////////////////////////////////////////////////////////////////////////////
13 
14 #ifndef BOOST_INTERPROCESS_DETAIL_POINTER_TYPE_HPP
15 #define BOOST_INTERPROCESS_DETAIL_POINTER_TYPE_HPP
16 
17 #ifndef BOOST_CONFIG_HPP
18 #  include <boost/config.hpp>
19 #endif
20 #
21 #if defined(BOOST_HAS_PRAGMA_ONCE)
22 #  pragma once
23 #endif
24 
25 #include <boost/interprocess/detail/config_begin.hpp>
26 #include <boost/interprocess/detail/workaround.hpp>
27 #include <boost/interprocess/detail/type_traits.hpp>
28 
29 namespace boost {
30 namespace interprocess {
31 namespace ipcdetail {
32 
33 struct two {char _[2];};
34 
35 namespace pointer_type_imp {
36 
37 template <class U> static two  test(...);
38 template <class U> static char test(typename U::pointer* = 0);
39 
40 }  //namespace pointer_type_imp {
41 
42 template <class T>
43 struct has_pointer_type
44 {
45     static const bool value = sizeof(pointer_type_imp::test<T>(0)) == 1;
46 };
47 
48 namespace pointer_type_imp {
49 
50 template <class T, class D, bool = has_pointer_type<D>::value>
51 struct pointer_type
52 {
53     typedef typename D::pointer type;
54 };
55 
56 template <class T, class D>
57 struct pointer_type<T, D, false>
58 {
59     typedef T* type;
60 };
61 
62 }  //namespace pointer_type_imp {
63 
64 template <class T, class D>
65 struct pointer_type
66 {
67     typedef typename pointer_type_imp::pointer_type<T,
68         typename remove_reference<D>::type>::type type;
69 };
70 
71 }  //namespace ipcdetail {
72 }  //namespace interprocess {
73 }  //namespace boost {
74 
75 #include <boost/interprocess/detail/config_end.hpp>
76 
77 #endif   //#ifndef BOOST_INTERPROCESS_DETAIL_POINTER_TYPE_HPP
78 
79