Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | // Copyright (C) 2004 Peder Holt |
| 2 | // Use, modification and distribution is subject to the Boost Software |
| 3 | // License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) |
| 4 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 5 | #ifndef NDNBOOST_TYPE_TRAITS_MSVC_REMOVE_POINTER_HOLT_2004_0827 |
| 6 | #define NDNBOOST_TYPE_TRAITS_MSVC_REMOVE_POINTER_HOLT_2004_0827 |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 7 | |
| 8 | #include <ndnboost/type_traits/msvc/typeof.hpp> |
| 9 | #include <ndnboost/type_traits/is_pointer.hpp> |
| 10 | |
| 11 | namespace ndnboost { |
| 12 | namespace detail { |
| 13 | template<int IsPointer> |
| 14 | struct remove_pointer_impl_typeof { |
| 15 | template<typename T,typename ID> |
| 16 | struct inner { |
| 17 | typedef T type; |
| 18 | }; |
| 19 | }; |
| 20 | template<> |
| 21 | struct remove_pointer_impl_typeof<true> { |
| 22 | template<typename T,typename ID> |
| 23 | struct inner { |
| 24 | template<typename U> |
| 25 | static msvc_register_type<U,ID> test(U*); |
| 26 | static msvc_register_type<T,ID> test(...); |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 27 | NDNBOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( *((T*)NULL) ) )); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 28 | typedef typename msvc_extract_type<ID>::id2type::type type; |
| 29 | }; |
| 30 | }; |
| 31 | } //namespace detail |
| 32 | |
| 33 | template<typename T> |
| 34 | struct remove_pointer { |
| 35 | typedef typename ndnboost::detail::remove_pointer_impl_typeof< |
| 36 | ndnboost::is_pointer<T>::value |
| 37 | >::template inner<T,remove_pointer<T> >::type type; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 38 | NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(1,remove_pointer,T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 39 | }; |
| 40 | } //namespace ndnboost |
| 41 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 42 | #endif //NDNBOOST_TYPE_TRAITS_REMOVE_POINTER_HOLT_2004_0827 |