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_SEQUENCE_TAG_HPP_INCLUDED |
| 3 | #define NDNBOOST_MPL_SEQUENCE_TAG_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 4 | |
| 5 | // Copyright Aleksey Gurtovoy 2000-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: sequence_tag.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/sequence_tag_fwd.hpp> |
| 18 | #include <ndnboost/mpl/aux_/has_tag.hpp> |
| 19 | #include <ndnboost/mpl/aux_/has_begin.hpp> |
| 20 | #include <ndnboost/mpl/aux_/na_spec.hpp> |
| 21 | #include <ndnboost/mpl/aux_/is_msvc_eti_arg.hpp> |
| 22 | #include <ndnboost/mpl/aux_/config/eti.hpp> |
| 23 | #include <ndnboost/mpl/aux_/yes_no.hpp> |
| 24 | #include <ndnboost/mpl/aux_/config/workaround.hpp> |
| 25 | |
| 26 | namespace ndnboost { namespace mpl { |
| 27 | |
| 28 | // agurt, 27/nov/02: have to use a simplistic 'sequence_tag' implementation |
| 29 | // on MSVC to avoid dreadful "internal structure overflow" error |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 30 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300) \ |
| 31 | || defined(NDNBOOST_MPL_CFG_NO_HAS_XXX) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 32 | |
| 33 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 34 | typename NDNBOOST_MPL_AUX_NA_PARAM(Sequence) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 35 | > |
| 36 | struct sequence_tag |
| 37 | { |
| 38 | typedef typename Sequence::tag type; |
| 39 | }; |
| 40 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 41 | #elif NDNBOOST_WORKAROUND(NDNBOOST_MSVC, == 1300) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 42 | |
| 43 | // agurt, 07/feb/03: workaround for what seems to be MSVC 7.0-specific ETI issue |
| 44 | |
| 45 | namespace aux { |
| 46 | |
| 47 | template< bool > |
| 48 | struct sequence_tag_impl |
| 49 | { |
| 50 | template< typename Sequence > struct result_ |
| 51 | { |
| 52 | typedef typename Sequence::tag type; |
| 53 | }; |
| 54 | }; |
| 55 | |
| 56 | template<> |
| 57 | struct sequence_tag_impl<false> |
| 58 | { |
| 59 | template< typename Sequence > struct result_ |
| 60 | { |
| 61 | typedef int type; |
| 62 | }; |
| 63 | }; |
| 64 | |
| 65 | } // namespace aux |
| 66 | |
| 67 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 68 | typename NDNBOOST_MPL_AUX_NA_PARAM(Sequence) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 69 | > |
| 70 | struct sequence_tag |
| 71 | : aux::sequence_tag_impl< !aux::is_msvc_eti_arg<Sequence>::value > |
| 72 | ::template result_<Sequence> |
| 73 | { |
| 74 | }; |
| 75 | |
| 76 | #else |
| 77 | |
| 78 | namespace aux { |
| 79 | |
| 80 | template< bool has_tag_, bool has_begin_ > |
| 81 | struct sequence_tag_impl |
| 82 | { |
| 83 | // agurt 24/nov/02: MSVC 6.5 gets confused in 'sequence_tag_impl<true>' |
| 84 | // specialization below, if we name it 'result_' here |
| 85 | template< typename Sequence > struct result2_; |
| 86 | }; |
| 87 | |
| 88 | # define AUX_CLASS_SEQUENCE_TAG_SPEC(has_tag, has_begin, result_type) \ |
| 89 | template<> struct sequence_tag_impl<has_tag,has_begin> \ |
| 90 | { \ |
| 91 | template< typename Sequence > struct result2_ \ |
| 92 | { \ |
| 93 | typedef result_type type; \ |
| 94 | }; \ |
| 95 | }; \ |
| 96 | /**/ |
| 97 | |
| 98 | AUX_CLASS_SEQUENCE_TAG_SPEC(true, true, typename Sequence::tag) |
| 99 | AUX_CLASS_SEQUENCE_TAG_SPEC(true, false, typename Sequence::tag) |
| 100 | AUX_CLASS_SEQUENCE_TAG_SPEC(false, true, nested_begin_end_tag) |
| 101 | AUX_CLASS_SEQUENCE_TAG_SPEC(false, false, non_sequence_tag) |
| 102 | |
| 103 | # undef AUX_CLASS_SEQUENCE_TAG_SPEC |
| 104 | |
| 105 | } // namespace aux |
| 106 | |
| 107 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 108 | typename NDNBOOST_MPL_AUX_NA_PARAM(Sequence) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 109 | > |
| 110 | struct sequence_tag |
| 111 | : aux::sequence_tag_impl< |
| 112 | ::ndnboost::mpl::aux::has_tag<Sequence>::value |
| 113 | , ::ndnboost::mpl::aux::has_begin<Sequence>::value |
| 114 | >::template result2_<Sequence> |
| 115 | { |
| 116 | }; |
| 117 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 118 | #endif // NDNBOOST_MSVC |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 119 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 120 | NDNBOOST_MPL_AUX_NA_SPEC(1, sequence_tag) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 121 | |
| 122 | }} |
| 123 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 124 | #endif // NDNBOOST_MPL_SEQUENCE_TAG_HPP_INCLUDED |