blob: 9e629f01b63948d3c890eb90ed1a4dae1d38f94d [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
Jeff Thompson3d613fd2013-10-15 15:39:04 -07002#if !defined(NDNBOOST_PP_IS_ITERATING)
Jeff Thompsona28eed82013-08-22 16:21:10 -07003
4///// header body
5
Jeff Thompson3d613fd2013-10-15 15:39:04 -07006#ifndef NDNBOOST_MPL_AUX778076_ADVANCE_BACKWARD_HPP_INCLUDED
7#define NDNBOOST_MPL_AUX778076_ADVANCE_BACKWARD_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -07008
9// Copyright Aleksey Gurtovoy 2000-2004
10//
11// Distributed under the Boost Software License, Version 1.0.
12// (See accompanying file LICENSE_1_0.txt or copy at
13// http://www.boost.org/LICENSE_1_0.txt)
14//
15// See http://www.boost.org/libs/mpl for documentation.
16
17// $Id: advance_backward.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
18// $Date: 2008-10-10 23:19:02 -0700 (Fri, 10 Oct 2008) $
19// $Revision: 49267 $
20
Jeff Thompson3d613fd2013-10-15 15:39:04 -070021#if !defined(NDNBOOST_MPL_PREPROCESSING_MODE)
Jeff Thompsona28eed82013-08-22 16:21:10 -070022# include <ndnboost/mpl/prior.hpp>
23# include <ndnboost/mpl/apply_wrap.hpp>
24#endif
25
26#include <ndnboost/mpl/aux_/config/use_preprocessed.hpp>
27
Jeff Thompson3d613fd2013-10-15 15:39:04 -070028#if !defined(NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
29 && !defined(NDNBOOST_MPL_PREPROCESSING_MODE)
Jeff Thompsona28eed82013-08-22 16:21:10 -070030
Jeff Thompson3d613fd2013-10-15 15:39:04 -070031# define NDNBOOST_MPL_PREPROCESSED_HEADER advance_backward.hpp
Jeff Thompsona28eed82013-08-22 16:21:10 -070032# include <ndnboost/mpl/aux_/include_preprocessed.hpp>
33
34#else
35
36# include <ndnboost/mpl/limits/unrolling.hpp>
37# include <ndnboost/mpl/aux_/nttp_decl.hpp>
38# include <ndnboost/mpl/aux_/config/eti.hpp>
39
40# include <ndnboost/preprocessor/iterate.hpp>
41# include <ndnboost/preprocessor/cat.hpp>
42# include <ndnboost/preprocessor/inc.hpp>
43
44namespace ndnboost { namespace mpl { namespace aux {
45
46// forward declaration
Jeff Thompson3d613fd2013-10-15 15:39:04 -070047template< NDNBOOST_MPL_AUX_NTTP_DECL(long, N) > struct advance_backward;
Jeff Thompsona28eed82013-08-22 16:21:10 -070048
Jeff Thompson3d613fd2013-10-15 15:39:04 -070049# define NDNBOOST_PP_ITERATION_PARAMS_1 \
50 (3,(0, NDNBOOST_MPL_LIMIT_UNROLLING, <ndnboost/mpl/aux_/advance_backward.hpp>))
51# include NDNBOOST_PP_ITERATE()
Jeff Thompsona28eed82013-08-22 16:21:10 -070052
Jeff Thompson3d613fd2013-10-15 15:39:04 -070053// implementation for N that exceeds NDNBOOST_MPL_LIMIT_UNROLLING
54template< NDNBOOST_MPL_AUX_NTTP_DECL(long, N) >
Jeff Thompsona28eed82013-08-22 16:21:10 -070055struct advance_backward
56{
57 template< typename Iterator > struct apply
58 {
59 typedef typename apply_wrap1<
Jeff Thompson3d613fd2013-10-15 15:39:04 -070060 advance_backward<NDNBOOST_MPL_LIMIT_UNROLLING>
Jeff Thompsona28eed82013-08-22 16:21:10 -070061 , Iterator
62 >::type chunk_result_;
63
64 typedef typename apply_wrap1<
65 advance_backward<(
Jeff Thompson3d613fd2013-10-15 15:39:04 -070066 (N - NDNBOOST_MPL_LIMIT_UNROLLING) < 0
Jeff Thompsona28eed82013-08-22 16:21:10 -070067 ? 0
Jeff Thompson3d613fd2013-10-15 15:39:04 -070068 : N - NDNBOOST_MPL_LIMIT_UNROLLING
Jeff Thompsona28eed82013-08-22 16:21:10 -070069 )>
70 , chunk_result_
71 >::type type;
72 };
73};
74
75}}}
76
Jeff Thompson3d613fd2013-10-15 15:39:04 -070077#endif // NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
78#endif // NDNBOOST_MPL_AUX778076_ADVANCE_BACKWARD_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -070079
80///// iteration, depth == 1
81
82// For gcc 4.4 compatability, we must include the
Jeff Thompson3d613fd2013-10-15 15:39:04 -070083// NDNBOOST_PP_ITERATION_DEPTH test inside an #else clause.
84#else // NDNBOOST_PP_IS_ITERATING
85#if NDNBOOST_PP_ITERATION_DEPTH() == 1
86#define i_ NDNBOOST_PP_FRAME_ITERATION(1)
Jeff Thompsona28eed82013-08-22 16:21:10 -070087
88template<>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070089struct advance_backward< NDNBOOST_PP_FRAME_ITERATION(1) >
Jeff Thompsona28eed82013-08-22 16:21:10 -070090{
91 template< typename Iterator > struct apply
92 {
93 typedef Iterator iter0;
94
95#if i_ > 0
Jeff Thompson3d613fd2013-10-15 15:39:04 -070096# define NDNBOOST_PP_ITERATION_PARAMS_2 \
97 (3,(1, NDNBOOST_PP_FRAME_ITERATION(1), <ndnboost/mpl/aux_/advance_backward.hpp>))
98# include NDNBOOST_PP_ITERATE()
Jeff Thompsona28eed82013-08-22 16:21:10 -070099#endif
100
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700101 typedef NDNBOOST_PP_CAT(iter,NDNBOOST_PP_FRAME_ITERATION(1)) type;
Jeff Thompsona28eed82013-08-22 16:21:10 -0700102 };
103
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700104#if defined(NDNBOOST_MPL_CFG_MSVC_60_ETI_BUG)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700105 /// ETI workaround
106 template<> struct apply<int>
107 {
108 typedef int type;
109 };
110#endif
111};
112
113#undef i_
114
115///// iteration, depth == 2
116
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700117#elif NDNBOOST_PP_ITERATION_DEPTH() == 2
Jeff Thompsona28eed82013-08-22 16:21:10 -0700118
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700119# define AUX778076_ITER_0 NDNBOOST_PP_CAT(iter,NDNBOOST_PP_DEC(NDNBOOST_PP_FRAME_ITERATION(2)))
120# define AUX778076_ITER_1 NDNBOOST_PP_CAT(iter,NDNBOOST_PP_FRAME_ITERATION(2))
Jeff Thompsona28eed82013-08-22 16:21:10 -0700121
122 typedef typename prior<AUX778076_ITER_0>::type AUX778076_ITER_1;
123
124# undef AUX778076_ITER_1
125# undef AUX778076_ITER_0
126
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700127#endif // NDNBOOST_PP_ITERATION_DEPTH()
128#endif // NDNBOOST_PP_IS_ITERATING