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_VECTOR_AUX_AT_HPP_INCLUDED |
| 3 | #define NDNBOOST_MPL_VECTOR_AUX_AT_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: at.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/at_fwd.hpp> |
| 18 | #include <ndnboost/mpl/vector/aux_/tag.hpp> |
| 19 | #include <ndnboost/mpl/long.hpp> |
| 20 | #include <ndnboost/mpl/void.hpp> |
| 21 | #include <ndnboost/mpl/aux_/nttp_decl.hpp> |
| 22 | #include <ndnboost/mpl/aux_/type_wrapper.hpp> |
| 23 | #include <ndnboost/mpl/aux_/value_wknd.hpp> |
| 24 | #include <ndnboost/mpl/aux_/config/typeof.hpp> |
| 25 | #include <ndnboost/mpl/aux_/config/ctps.hpp> |
| 26 | |
| 27 | namespace ndnboost { namespace mpl { |
| 28 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 29 | #if defined(NDNBOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 30 | |
| 31 | template< typename Vector, long n_ > |
| 32 | struct v_at_impl |
| 33 | { |
| 34 | typedef long_< (Vector::lower_bound_::value + n_) > index_; |
| 35 | typedef __typeof__( Vector::item_(index_()) ) type; |
| 36 | }; |
| 37 | |
| 38 | |
| 39 | template< typename Vector, long n_ > |
| 40 | struct v_at |
| 41 | : aux::wrapped_type< typename v_at_impl<Vector,n_>::type > |
| 42 | { |
| 43 | }; |
| 44 | |
| 45 | template<> |
| 46 | struct at_impl< aux::vector_tag > |
| 47 | { |
| 48 | template< typename Vector, typename N > struct apply |
| 49 | : v_at< |
| 50 | Vector |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 51 | , NDNBOOST_MPL_AUX_VALUE_WKND(N)::value |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 52 | > |
| 53 | { |
| 54 | }; |
| 55 | }; |
| 56 | |
| 57 | #else |
| 58 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 59 | # if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ |
| 60 | && !defined(NDNBOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 61 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 62 | template< typename Vector, NDNBOOST_MPL_AUX_NTTP_DECL(long, n_) > struct v_at; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 63 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 64 | template< NDNBOOST_MPL_AUX_NTTP_DECL(long, n_) > |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 65 | struct at_impl< aux::vector_tag<n_> > |
| 66 | { |
| 67 | template< typename Vector, typename N > struct apply |
| 68 | #if !defined(__BORLANDC__) |
| 69 | : v_at< |
| 70 | Vector |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 71 | , NDNBOOST_MPL_AUX_VALUE_WKND(N)::value |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 72 | > |
| 73 | { |
| 74 | #else |
| 75 | { |
| 76 | typedef typename v_at< |
| 77 | Vector |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 78 | , NDNBOOST_MPL_AUX_VALUE_WKND(N)::value |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 79 | >::type type; |
| 80 | #endif |
| 81 | }; |
| 82 | }; |
| 83 | |
| 84 | # else |
| 85 | |
| 86 | namespace aux { |
| 87 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 88 | template< NDNBOOST_MPL_AUX_NTTP_DECL(long, n_) > struct v_at_impl |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 89 | { |
| 90 | template< typename V > struct result_; |
| 91 | }; |
| 92 | |
| 93 | // to work around ETI, etc. |
| 94 | template<> struct v_at_impl<-1> |
| 95 | { |
| 96 | template< typename V > struct result_ |
| 97 | { |
| 98 | typedef void_ type; |
| 99 | }; |
| 100 | }; |
| 101 | |
| 102 | } // namespace aux |
| 103 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 104 | template< typename T, NDNBOOST_MPL_AUX_NTTP_DECL(long, n_) > |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 105 | struct v_at |
| 106 | : aux::v_at_impl<n_>::template result_<T> |
| 107 | { |
| 108 | }; |
| 109 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 110 | # endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 111 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 112 | #endif // NDNBOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 113 | |
| 114 | }} |
| 115 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 116 | #endif // NDNBOOST_MPL_VECTOR_AUX_AT_HPP_INCLUDED |