Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
| 2 | // (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard |
| 3 | // Hinnant & John Maddock 2000. |
| 4 | // Use, modification and distribution are subject to the Boost Software License, |
| 5 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 6 | // http://www.boost.org/LICENSE_1_0.txt). |
| 7 | // |
| 8 | // See http://www.boost.org/libs/type_traits for most recent version including documentation. |
| 9 | |
| 10 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 11 | #ifndef NDNBOOST_TT_REMOVE_CONST_HPP_INCLUDED |
| 12 | #define NDNBOOST_TT_REMOVE_CONST_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 13 | |
| 14 | #include <ndnboost/type_traits/is_volatile.hpp> |
| 15 | #include <ndnboost/type_traits/broken_compiler_spec.hpp> |
| 16 | #include <ndnboost/type_traits/detail/cv_traits_impl.hpp> |
| 17 | #include <ndnboost/config.hpp> |
| 18 | #include <ndnboost/detail/workaround.hpp> |
| 19 | |
| 20 | #include <cstddef> |
| 21 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 22 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC,<=1300) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 23 | #include <ndnboost/type_traits/msvc/remove_const.hpp> |
| 24 | #endif |
| 25 | |
| 26 | // should be the last #include |
| 27 | #include <ndnboost/type_traits/detail/type_trait_def.hpp> |
| 28 | |
| 29 | namespace ndnboost { |
| 30 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 31 | #ifndef NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 32 | |
| 33 | namespace detail { |
| 34 | |
| 35 | template <typename T, bool is_vol> |
| 36 | struct remove_const_helper |
| 37 | { |
| 38 | typedef T type; |
| 39 | }; |
| 40 | |
| 41 | template <typename T> |
| 42 | struct remove_const_helper<T, true> |
| 43 | { |
| 44 | typedef T volatile type; |
| 45 | }; |
| 46 | |
| 47 | |
| 48 | template <typename T> |
| 49 | struct remove_const_impl |
| 50 | { |
| 51 | typedef typename remove_const_helper< |
| 52 | typename cv_traits_imp<T*>::unqualified_type |
| 53 | , ::ndnboost::is_volatile<T>::value |
| 54 | >::type type; |
| 55 | }; |
| 56 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 57 | #ifndef NDNBOOST_NO_CXX11_RVALUE_REFERENCES |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 58 | // |
| 59 | // We can't filter out rvalue_references at the same level as |
| 60 | // references or we get ambiguities from msvc: |
| 61 | // |
| 62 | template <typename T> |
| 63 | struct remove_const_impl<T&&> |
| 64 | { |
| 65 | typedef T&& type; |
| 66 | }; |
| 67 | #endif |
| 68 | |
| 69 | } // namespace detail |
| 70 | |
| 71 | // * convert a type T to non-const type - remove_const<T> |
| 72 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 73 | NDNBOOST_TT_AUX_TYPE_TRAIT_DEF1(remove_const,T,typename ndnboost::detail::remove_const_impl<T>::type) |
| 74 | NDNBOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,remove_const,T&,T&) |
| 75 | #if !defined(NDNBOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) |
| 76 | NDNBOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,remove_const,T const[N],T type[N]) |
| 77 | NDNBOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,remove_const,T const volatile[N],T volatile type[N]) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 78 | #endif |
| 79 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 80 | #elif !NDNBOOST_WORKAROUND(NDNBOOST_MSVC,<=1300) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 81 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 82 | NDNBOOST_TT_AUX_TYPE_TRAIT_DEF1(remove_const,T,typename ndnboost::detail::remove_const_impl<T>::type) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 83 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 84 | #endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 85 | |
| 86 | } // namespace ndnboost |
| 87 | |
| 88 | #include <ndnboost/type_traits/detail/type_trait_undef.hpp> |
| 89 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 90 | #endif // NDNBOOST_TT_REMOVE_CONST_HPP_INCLUDED |