Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -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_DETAIL_CV_TRAITS_IMPL_HPP_INCLUDED |
| 12 | #define NDNBOOST_TT_DETAIL_CV_TRAITS_IMPL_HPP_INCLUDED |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 13 | |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 14 | #include <ndnboost/config.hpp> |
| 15 | #include <ndnboost/detail/workaround.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 16 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 17 | #ifndef NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 18 | |
| 19 | // implementation helper: |
| 20 | |
| 21 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 22 | #if !(NDNBOOST_WORKAROUND(__GNUC__,== 3) && NDNBOOST_WORKAROUND(__GNUC_MINOR__, <= 2)) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 23 | namespace ndnboost { |
| 24 | namespace detail { |
| 25 | #else |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 26 | #include <ndnboost/type_traits/detail/yes_no_type.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 27 | namespace ndnboost { |
| 28 | namespace type_traits { |
| 29 | namespace gcc8503 { |
| 30 | #endif |
| 31 | |
| 32 | template <typename T> struct cv_traits_imp {}; |
| 33 | |
| 34 | template <typename T> |
| 35 | struct cv_traits_imp<T*> |
| 36 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 37 | NDNBOOST_STATIC_CONSTANT(bool, is_const = false); |
| 38 | NDNBOOST_STATIC_CONSTANT(bool, is_volatile = false); |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 39 | typedef T unqualified_type; |
| 40 | }; |
| 41 | |
| 42 | template <typename T> |
| 43 | struct cv_traits_imp<const T*> |
| 44 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 45 | NDNBOOST_STATIC_CONSTANT(bool, is_const = true); |
| 46 | NDNBOOST_STATIC_CONSTANT(bool, is_volatile = false); |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 47 | typedef T unqualified_type; |
| 48 | }; |
| 49 | |
| 50 | template <typename T> |
| 51 | struct cv_traits_imp<volatile T*> |
| 52 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 53 | NDNBOOST_STATIC_CONSTANT(bool, is_const = false); |
| 54 | NDNBOOST_STATIC_CONSTANT(bool, is_volatile = true); |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 55 | typedef T unqualified_type; |
| 56 | }; |
| 57 | |
| 58 | template <typename T> |
| 59 | struct cv_traits_imp<const volatile T*> |
| 60 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 61 | NDNBOOST_STATIC_CONSTANT(bool, is_const = true); |
| 62 | NDNBOOST_STATIC_CONSTANT(bool, is_volatile = true); |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 63 | typedef T unqualified_type; |
| 64 | }; |
| 65 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 66 | #if NDNBOOST_WORKAROUND(__GNUC__,== 3) && NDNBOOST_WORKAROUND(__GNUC_MINOR__, <= 2) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 67 | // We have to exclude function pointers |
| 68 | // (see http://gcc.gnu.org/bugzilla/show_bug.cgi?8503) |
| 69 | yes_type mini_funcptr_tester(...); |
| 70 | no_type mini_funcptr_tester(const volatile void*); |
| 71 | |
| 72 | } // namespace gcc8503 |
| 73 | } // namespace type_traits |
| 74 | |
| 75 | namespace detail { |
| 76 | |
| 77 | // Use the implementation above for non function pointers |
| 78 | template <typename T, unsigned Select |
| 79 | = (unsigned)sizeof(::ndnboost::type_traits::gcc8503::mini_funcptr_tester((T)0)) > |
| 80 | struct cv_traits_imp : public ::ndnboost::type_traits::gcc8503::cv_traits_imp<T> { }; |
| 81 | |
| 82 | // Functions are never cv-qualified |
| 83 | template <typename T> struct cv_traits_imp<T*,1> |
| 84 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 85 | NDNBOOST_STATIC_CONSTANT(bool, is_const = false); |
| 86 | NDNBOOST_STATIC_CONSTANT(bool, is_volatile = false); |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 87 | typedef T unqualified_type; |
| 88 | }; |
| 89 | |
| 90 | #endif |
| 91 | |
| 92 | } // namespace detail |
| 93 | } // namespace ndnboost |
| 94 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 95 | #endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 96 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 97 | #endif // NDNBOOST_TT_DETAIL_CV_TRAITS_IMPL_HPP_INCLUDED |