New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
filtered.hpp in vendors/XIOS/current/extern/boost/include/boost/range/adaptor – NEMO

source: vendors/XIOS/current/extern/boost/include/boost/range/adaptor/filtered.hpp @ 3428

Last change on this file since 3428 was 3428, checked in by rblod, 12 years ago

importing initial XIOS vendor drop

File size: 3.2 KB
Line 
1// Boost.Range library
2//
3//  Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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_ADAPTOR_FILTERED_HPP
12#define BOOST_RANGE_ADAPTOR_FILTERED_HPP
13
14#include <boost/range/adaptor/argument_fwd.hpp>
15#include <boost/range/iterator_range.hpp>
16#include <boost/iterator/filter_iterator.hpp>
17
18namespace boost
19{
20    namespace range_detail
21    {
22        template< class P, class R >
23        struct filter_range :
24            boost::iterator_range<
25                boost::filter_iterator< P,
26                    BOOST_DEDUCED_TYPENAME range_iterator<R>::type
27                >
28            >
29        {
30        private:
31            typedef boost::iterator_range<
32                        boost::filter_iterator< P,
33                            BOOST_DEDUCED_TYPENAME range_iterator<R>::type
34                        >
35                    > base;
36        public:
37            filter_range( P p, R& r )
38            : base( make_filter_iterator( p, boost::begin(r), boost::end(r) ),
39                    make_filter_iterator( p, boost::end(r), boost::end(r) ) )
40            { }
41        };
42
43        template< class T >
44        struct filter_holder : holder<T>
45        {
46            filter_holder( T r ) : holder<T>(r)
47            { }
48        };
49
50        template< class InputRng, class Predicate >
51        inline filter_range<Predicate, InputRng>
52        operator|( InputRng& r,
53                   const filter_holder<Predicate>& f )
54        {
55            return filter_range<Predicate, InputRng>( f.val, r );
56        }
57
58        template< class InputRng, class Predicate >
59        inline filter_range<Predicate, const InputRng>
60        operator|( const InputRng& r,
61                   const filter_holder<Predicate>& f )
62        {
63            return filter_range<Predicate, const InputRng>( f.val, r );
64        }
65
66    } // 'range_detail'
67
68    // Unusual use of 'using' is intended to bring filter_range into the boost namespace
69    // while leaving the mechanics of the '|' operator in range_detail and maintain
70    // argument dependent lookup.
71    // filter_range logically needs to be in the boost namespace to allow user of
72    // the library to define the return type for filter()
73    using range_detail::filter_range;
74
75    namespace adaptors
76    {
77        namespace
78        {
79            const range_detail::forwarder<range_detail::filter_holder>
80                    filtered =
81                       range_detail::forwarder<range_detail::filter_holder>();
82        }
83
84        template<class InputRange, class Predicate>
85        inline filter_range<Predicate, InputRange>
86        filter(InputRange& rng, Predicate filter_pred)
87        {
88            return range_detail::filter_range<Predicate, InputRange>( filter_pred, rng );
89        }
90
91        template<class InputRange, class Predicate>
92        inline filter_range<Predicate, const InputRange>
93        filter(const InputRange& rng, Predicate filter_pred)
94        {
95            return range_detail::filter_range<Predicate, const InputRange>( filter_pred, rng );
96        }
97    } // 'adaptors'
98
99}
100
101#endif
Note: See TracBrowser for help on using the repository browser.