blob: b5077435f89f4c078f1b05f1983acd0825d71b74 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
Jeff Thompson3d613fd2013-10-15 15:39:04 -07002#ifndef NDNBOOST_MPL_VECTOR_AUX_AT_HPP_INCLUDED
3#define NDNBOOST_MPL_VECTOR_AUX_AT_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -07004
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
27namespace ndnboost { namespace mpl {
28
Jeff Thompson3d613fd2013-10-15 15:39:04 -070029#if defined(NDNBOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
Jeff Thompsona28eed82013-08-22 16:21:10 -070030
31template< typename Vector, long n_ >
32struct v_at_impl
33{
34 typedef long_< (Vector::lower_bound_::value + n_) > index_;
35 typedef __typeof__( Vector::item_(index_()) ) type;
36};
37
38
39template< typename Vector, long n_ >
40struct v_at
41 : aux::wrapped_type< typename v_at_impl<Vector,n_>::type >
42{
43};
44
45template<>
46struct at_impl< aux::vector_tag >
47{
48 template< typename Vector, typename N > struct apply
49 : v_at<
50 Vector
Jeff Thompson3d613fd2013-10-15 15:39:04 -070051 , NDNBOOST_MPL_AUX_VALUE_WKND(N)::value
Jeff Thompsona28eed82013-08-22 16:21:10 -070052 >
53 {
54 };
55};
56
57#else
58
Jeff Thompson3d613fd2013-10-15 15:39:04 -070059# if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
60 && !defined(NDNBOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC)
Jeff Thompsona28eed82013-08-22 16:21:10 -070061
Jeff Thompson3d613fd2013-10-15 15:39:04 -070062template< typename Vector, NDNBOOST_MPL_AUX_NTTP_DECL(long, n_) > struct v_at;
Jeff Thompsona28eed82013-08-22 16:21:10 -070063
Jeff Thompson3d613fd2013-10-15 15:39:04 -070064template< NDNBOOST_MPL_AUX_NTTP_DECL(long, n_) >
Jeff Thompsona28eed82013-08-22 16:21:10 -070065struct 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 Thompson3d613fd2013-10-15 15:39:04 -070071 , NDNBOOST_MPL_AUX_VALUE_WKND(N)::value
Jeff Thompsona28eed82013-08-22 16:21:10 -070072 >
73 {
74#else
75 {
76 typedef typename v_at<
77 Vector
Jeff Thompson3d613fd2013-10-15 15:39:04 -070078 , NDNBOOST_MPL_AUX_VALUE_WKND(N)::value
Jeff Thompsona28eed82013-08-22 16:21:10 -070079 >::type type;
80#endif
81 };
82};
83
84# else
85
86namespace aux {
87
Jeff Thompson3d613fd2013-10-15 15:39:04 -070088template< NDNBOOST_MPL_AUX_NTTP_DECL(long, n_) > struct v_at_impl
Jeff Thompsona28eed82013-08-22 16:21:10 -070089{
90 template< typename V > struct result_;
91};
92
93// to work around ETI, etc.
94template<> 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 Thompson3d613fd2013-10-15 15:39:04 -0700104template< typename T, NDNBOOST_MPL_AUX_NTTP_DECL(long, n_) >
Jeff Thompsona28eed82013-08-22 16:21:10 -0700105struct v_at
106 : aux::v_at_impl<n_>::template result_<T>
107{
108};
109
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700110# endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Jeff Thompsona28eed82013-08-22 16:21:10 -0700111
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700112#endif // NDNBOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
Jeff Thompsona28eed82013-08-22 16:21:10 -0700113
114}}
115
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700116#endif // NDNBOOST_MPL_VECTOR_AUX_AT_HPP_INCLUDED