source: NonGTP/Boost/boost/range/iterator.hpp @ 857

Revision 857, 3.0 KB checked in by igarcia, 18 years ago (diff)
Line 
1// Boost.Range library
2//
3//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
4//  distribution is subject to the Boost Software License, Version
5//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
6//  http://www.boost.org/LICENSE_1_0.txt)
7//
8// For more information, see http://www.boost.org/libs/range/
9//
10
11#ifndef BOOST_RANGE_ITERATOR_HPP
12#define BOOST_RANGE_ITERATOR_HPP
13
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif
17
18#include <boost/range/config.hpp>
19
20#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
21#include <boost/range/detail/iterator.hpp>
22#else
23
24#include <boost/iterator/iterator_traits.hpp>
25#include <cstddef>
26#include <utility>
27
28namespace boost
29{
30    //////////////////////////////////////////////////////////////////////////
31    // default
32    //////////////////////////////////////////////////////////////////////////
33   
34    template< typename C >
35    struct range_iterator
36    {
37        typedef BOOST_DEDUCED_TYPENAME C::iterator type;
38    };
39   
40    //////////////////////////////////////////////////////////////////////////
41    // pair
42    //////////////////////////////////////////////////////////////////////////
43
44    template< typename Iterator >
45    struct range_iterator< std::pair<Iterator,Iterator> >
46    {
47        typedef Iterator type;
48    };
49   
50    template< typename Iterator >
51    struct range_iterator< const std::pair<Iterator,Iterator> >
52    {
53        typedef Iterator type;
54    };
55
56    //////////////////////////////////////////////////////////////////////////
57    // array
58    //////////////////////////////////////////////////////////////////////////
59
60    template< typename T, std::size_t sz >
61    struct range_iterator< T[sz] >
62    {
63        typedef T* type;
64    };
65
66    template< typename T, std::size_t sz >
67    struct range_iterator< const T[sz] >
68    {
69        typedef const T* type;
70    };
71
72    //////////////////////////////////////////////////////////////////////////
73    // string
74    //////////////////////////////////////////////////////////////////////////
75
76    template<>
77    struct range_iterator< char* >
78    {
79        typedef char* type;
80    };
81
82    template<>
83    struct range_iterator< wchar_t* >
84    {
85        typedef wchar_t* type;
86    };
87
88    template<>
89    struct range_iterator< const char* >
90    {
91        typedef const char* type;
92    };
93
94    template<>
95    struct range_iterator< const wchar_t* >
96    {
97        typedef const wchar_t* type;
98    };
99
100    template<>
101    struct range_iterator< char* const >
102    {
103        typedef char* type;
104    };
105
106    template<>
107    struct range_iterator< wchar_t* const >
108    {
109        typedef wchar_t* type;
110    };
111
112    template<>
113    struct range_iterator< const char* const >
114    {
115        typedef const char* type;
116    };
117
118    template<>
119    struct range_iterator< const wchar_t* const >
120    {
121        typedef const wchar_t* type;
122    };
123
124} // namespace boost
125
126#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
127
128#endif
Note: See TracBrowser for help on using the repository browser.