blob: aa8a2e861c8956ad14545bd1581a32418ab624ab [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
2// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
3// Use, modification and distribution are subject to the Boost Software License,
4// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt).
6//
7// See http://www.boost.org/libs/type_traits for most recent version including documentation.
8
Jeff Thompson3d613fd2013-10-15 15:39:04 -07009#ifndef NDNBOOST_TT_REMOVE_POINTER_HPP_INCLUDED
10#define NDNBOOST_TT_REMOVE_POINTER_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -070011
12#include <ndnboost/config.hpp>
13#include <ndnboost/detail/workaround.hpp>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070014#ifdef NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Jeff Thompsona28eed82013-08-22 16:21:10 -070015#include <ndnboost/type_traits/broken_compiler_spec.hpp>
16#endif
17
Jeff Thompson3d613fd2013-10-15 15:39:04 -070018#if NDNBOOST_WORKAROUND(NDNBOOST_MSVC,<=1300)
Jeff Thompsona28eed82013-08-22 16:21:10 -070019#include <ndnboost/type_traits/msvc/remove_pointer.hpp>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070020#elif defined(NDNBOOST_MSVC)
Jeff Thompsona28eed82013-08-22 16:21:10 -070021#include <ndnboost/type_traits/remove_cv.hpp>
22#include <ndnboost/type_traits/is_pointer.hpp>
23#endif
24
25// should be the last #include
26#include <ndnboost/type_traits/detail/type_trait_def.hpp>
27
28namespace ndnboost {
29
Jeff Thompson3d613fd2013-10-15 15:39:04 -070030#ifdef NDNBOOST_MSVC
Jeff Thompsona28eed82013-08-22 16:21:10 -070031
32namespace detail{
33
34 //
35 // We need all this crazy indirection because a type such as:
36 //
37 // T (*const)(U)
38 //
39 // Does not bind to a <T*> or <T*const> partial specialization with VC10 and earlier
40 //
41 template <class T>
42 struct remove_pointer_imp
43 {
44 typedef T type;
45 };
46
47 template <class T>
48 struct remove_pointer_imp<T*>
49 {
50 typedef T type;
51 };
52
53 template <class T, bool b>
54 struct remove_pointer_imp3
55 {
56 typedef typename remove_pointer_imp<typename ndnboost::remove_cv<T>::type>::type type;
57 };
58
59 template <class T>
60 struct remove_pointer_imp3<T, false>
61 {
62 typedef T type;
63 };
64
65 template <class T>
66 struct remove_pointer_imp2
67 {
68 typedef typename remove_pointer_imp3<T, ::ndnboost::is_pointer<T>::value>::type type;
69 };
70}
71
Jeff Thompson3d613fd2013-10-15 15:39:04 -070072NDNBOOST_TT_AUX_TYPE_TRAIT_DEF1(remove_pointer,T,typename ndnboost::detail::remove_pointer_imp2<T>::type)
Jeff Thompsona28eed82013-08-22 16:21:10 -070073
Jeff Thompson3d613fd2013-10-15 15:39:04 -070074#elif !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
Jeff Thompsona28eed82013-08-22 16:21:10 -070075
Jeff Thompson3d613fd2013-10-15 15:39:04 -070076NDNBOOST_TT_AUX_TYPE_TRAIT_DEF1(remove_pointer,T,T)
77NDNBOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,remove_pointer,T*,T)
78NDNBOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,remove_pointer,T* const,T)
79NDNBOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,remove_pointer,T* volatile,T)
80NDNBOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,remove_pointer,T* const volatile,T)
Jeff Thompsona28eed82013-08-22 16:21:10 -070081
Jeff Thompson3d613fd2013-10-15 15:39:04 -070082#elif !NDNBOOST_WORKAROUND(NDNBOOST_MSVC,<=1300)
Jeff Thompsona28eed82013-08-22 16:21:10 -070083
Jeff Thompson3d613fd2013-10-15 15:39:04 -070084NDNBOOST_TT_AUX_TYPE_TRAIT_DEF1(remove_pointer,T,typename ndnboost::detail::remove_pointer_impl<T>::type)
Jeff Thompsona28eed82013-08-22 16:21:10 -070085
86#endif
87
88} // namespace ndnboost
89
90#include <ndnboost/type_traits/detail/type_trait_undef.hpp>
91
Jeff Thompson3d613fd2013-10-15 15:39:04 -070092#endif // NDNBOOST_TT_REMOVE_POINTER_HPP_INCLUDED