~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to boost/boost/mpl/aux_/single_element_iter.hpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//-----------------------------------------------------------------------------
 
2
// boost mpl/aux_/single_element_iter.hpp header file
 
3
// See http://www.boost.org for updates, documentation, and revision history.
 
4
//-----------------------------------------------------------------------------
 
5
//
 
6
// Copyright (c) 2000-02
 
7
// Aleksey Gurtovoy
 
8
//
 
9
// Permission to use, copy, modify, distribute and sell this software
 
10
// and its documentation for any purpose is hereby granted without fee, 
 
11
// provided that the above copyright notice appears in all copies and 
 
12
// that both the copyright notice and this permission notice appear in 
 
13
// supporting documentation. No representations are made about the 
 
14
// suitability of this software for any purpose. It is provided "as is" 
 
15
// without express or implied warranty.
 
16
 
 
17
#ifndef BOOST_MPL_AUX_SINGLE_ELEMENT_ITER_HPP_INCLUDED
 
18
#define BOOST_MPL_AUX_SINGLE_ELEMENT_ITER_HPP_INCLUDED
 
19
 
 
20
#include "boost/mpl/iterator_tag.hpp"
 
21
#include "boost/mpl/plus.hpp"
 
22
#include "boost/mpl/minus.hpp"
 
23
#include "boost/mpl/int.hpp"
 
24
#include "boost/mpl/aux_/value_wknd.hpp"
 
25
#include "boost/mpl/aux_/iterator_names.hpp"
 
26
#include "boost/mpl/aux_/lambda_spec.hpp"
 
27
#include "boost/mpl/aux_/config/ctps.hpp"
 
28
#include "boost/mpl/aux_/config/nttp.hpp"
 
29
 
 
30
namespace boost { namespace mpl { 
 
31
 
 
32
namespace aux {
 
33
 
 
34
template< typename T, int N >
 
35
struct single_element_iter;
 
36
 
 
37
// random access support
 
38
template< typename T, BOOST_MPL_AUX_NTTP_DECL(int, N) >
 
39
struct single_iter_base
 
40
{
 
41
    typedef ra_iter_tag_ category;
 
42
    typedef int_<N> position;
 
43
 
 
44
    template< typename D >
 
45
    struct BOOST_MPL_AUX_ITERATOR_ADVANCE
 
46
    {
 
47
        typedef plus< int_<N>,D > n_;
 
48
        typedef single_element_iter<
 
49
              T
 
50
            , BOOST_MPL_AUX_VALUE_WKND(n_)::value
 
51
            > type;
 
52
    };
 
53
 
 
54
    template< typename U >
 
55
    struct BOOST_MPL_AUX_ITERATOR_DISTANCE
 
56
    {
 
57
        typedef typename minus<
 
58
              typename U::position
 
59
            , int_<N>
 
60
            >::type type;
 
61
    };
 
62
};
 
63
 
 
64
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
 
65
 
 
66
template< typename T >
 
67
struct single_element_iter<T,0>
 
68
    : single_iter_base<T,0>
 
69
{
 
70
    typedef single_element_iter<T,1> next;
 
71
    typedef T type;
 
72
};
 
73
 
 
74
template< typename T >
 
75
struct single_element_iter<T,1>
 
76
    : single_iter_base<T,1>
 
77
{
 
78
    typedef single_element_iter<T,0> prior;
 
79
};
 
80
 
 
81
#else
 
82
 
 
83
template< BOOST_MPL_AUX_NTTP_DECL(int, N) > struct single_iter_impl
 
84
{
 
85
    template< typename T > struct result_;
 
86
};
 
87
 
 
88
template<>
 
89
struct single_iter_impl<0>
 
90
{
 
91
    template< typename T > struct result_
 
92
        : single_iter_base<T,0>
 
93
    {
 
94
        typedef single_element_iter<T,1> next;
 
95
        typedef T type;
 
96
    };
 
97
};
 
98
 
 
99
template<>
 
100
struct single_iter_impl<1>
 
101
{
 
102
    template< typename T > struct result_
 
103
        : single_iter_base<T,1>
 
104
    {
 
105
        typedef single_element_iter<T,0> prior;
 
106
    };
 
107
};
 
108
 
 
109
template< typename T, BOOST_MPL_AUX_NTTP_DECL(int, N) >
 
110
struct single_element_iter
 
111
    : single_iter_impl<N>::template result_<T>
 
112
{
 
113
};
 
114
 
 
115
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 
116
 
 
117
} // namespace aux
 
118
 
 
119
//BOOST_MPL_AUX_PASS_THROUGH_LAMBDA_SPEC(1, aux::single_element_iter)
 
120
 
 
121
}} // namespace boost::mpl
 
122
 
 
123
#endif // BOOST_MPL_AUX_SINGLE_ELEMENT_ITER_HPP_INCLUDED