Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 2 | #ifndef NDNBOOST_MPL_IS_SEQUENCE_HPP_INCLUDED |
| 3 | #define NDNBOOST_MPL_IS_SEQUENCE_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 4 | |
| 5 | // Copyright Aleksey Gurtovoy 2002-2004 |
| 6 | // |
| 7 | // Distributed under the Boost Software License, Version 1.0. |
| 8 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 9 | // http://www.boost.org/LICENSE_1_0.txt) |
| 10 | // |
| 11 | // See http://www.boost.org/libs/mpl for documentation. |
| 12 | |
| 13 | // $Id: is_sequence.hpp 49267 2008-10-11 06:19:02Z agurtovoy $ |
| 14 | // $Date: 2008-10-10 23:19:02 -0700 (Fri, 10 Oct 2008) $ |
| 15 | // $Revision: 49267 $ |
| 16 | |
| 17 | #include <ndnboost/mpl/not.hpp> |
| 18 | #include <ndnboost/mpl/and.hpp> |
| 19 | #include <ndnboost/mpl/begin_end.hpp> |
| 20 | #include <ndnboost/mpl/if.hpp> |
| 21 | #include <ndnboost/mpl/bool.hpp> |
| 22 | #include <ndnboost/mpl/sequence_tag_fwd.hpp> |
| 23 | #include <ndnboost/mpl/identity.hpp> |
| 24 | #include <ndnboost/mpl/void.hpp> |
| 25 | #include <ndnboost/mpl/aux_/has_tag.hpp> |
| 26 | #include <ndnboost/mpl/aux_/has_begin.hpp> |
| 27 | #include <ndnboost/mpl/aux_/na_spec.hpp> |
| 28 | #include <ndnboost/mpl/aux_/lambda_support.hpp> |
| 29 | #include <ndnboost/mpl/aux_/config/eti.hpp> |
| 30 | #include <ndnboost/mpl/aux_/config/msvc.hpp> |
| 31 | #include <ndnboost/mpl/aux_/config/workaround.hpp> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 32 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 33 | # include <ndnboost/mpl/aux_/msvc_is_class.hpp> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 34 | #elif NDNBOOST_WORKAROUND(NDNBOOST_MSVC, == 1300) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 35 | # include <ndnboost/type_traits/is_class.hpp> |
| 36 | #endif |
| 37 | |
| 38 | #include <ndnboost/type_traits/is_same.hpp> |
| 39 | |
| 40 | namespace ndnboost { namespace mpl { |
| 41 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 42 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 43 | |
| 44 | namespace aux { |
| 45 | |
| 46 | // agurt, 11/jun/03: |
| 47 | // MSVC 6.5/7.0 fails if 'has_begin' is instantiated on a class type that has a |
| 48 | // 'begin' member that doesn't name a type; e.g. 'has_begin< std::vector<int> >' |
| 49 | // would fail; requiring 'T' to have _both_ 'tag' and 'begin' members workarounds |
| 50 | // the issue for most real-world cases |
| 51 | template< typename T > struct is_sequence_impl |
| 52 | : and_< |
| 53 | identity< aux::has_tag<T> > |
| 54 | , identity< aux::has_begin<T> > |
| 55 | > |
| 56 | { |
| 57 | }; |
| 58 | |
| 59 | } // namespace aux |
| 60 | |
| 61 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 62 | typename NDNBOOST_MPL_AUX_NA_PARAM(T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 63 | > |
| 64 | struct is_sequence |
| 65 | : if_< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 66 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 67 | aux::msvc_is_class<T> |
| 68 | #else |
| 69 | ndnboost::is_class<T> |
| 70 | #endif |
| 71 | , aux::is_sequence_impl<T> |
| 72 | , bool_<false> |
| 73 | >::type |
| 74 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 75 | NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(1, is_sequence, (T)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 78 | #elif defined(NDNBOOST_MPL_CFG_NO_HAS_XXX) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 79 | |
| 80 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 81 | typename NDNBOOST_MPL_AUX_NA_PARAM(T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 82 | > |
| 83 | struct is_sequence |
| 84 | : bool_<false> |
| 85 | { |
| 86 | }; |
| 87 | |
| 88 | #else |
| 89 | |
| 90 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 91 | typename NDNBOOST_MPL_AUX_NA_PARAM(T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 92 | > |
| 93 | struct is_sequence |
| 94 | : not_< is_same< typename begin<T>::type, void_ > > |
| 95 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 96 | NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(1, is_sequence, (T)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 99 | #endif // NDNBOOST_MSVC |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 100 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 101 | #if defined(NDNBOOST_MPL_CFG_MSVC_60_ETI_BUG) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 102 | template<> struct is_sequence<int> |
| 103 | : bool_<false> |
| 104 | { |
| 105 | }; |
| 106 | #endif |
| 107 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 108 | NDNBOOST_MPL_AUX_NA_SPEC_NO_ETI(1, is_sequence) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 109 | |
| 110 | }} |
| 111 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 112 | #endif // NDNBOOST_MPL_IS_SEQUENCE_HPP_INCLUDED |