PageRenderTime 40ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 28ms

/Src/Dependencies/Boost/boost/range/adaptor/copied.hpp

http://hadesmem.googlecode.com/
C++ Header | 58 lines | 40 code | 9 blank | 9 comment | 0 complexity | 08deff0f6cc1c7ae42122e02140b8fb8 MD5 | raw file
 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_COPIED_HPP
12#define BOOST_RANGE_ADAPTOR_COPIED_HPP
13
14#include <boost/range/adaptor/argument_fwd.hpp>
15#include <boost/range/adaptor/sliced.hpp>
16#include <boost/range/size_type.hpp>
17#include <boost/range/iterator_range.hpp>
18
19namespace boost
20{
21    namespace adaptors
22    {
23        struct copied
24        {
25            copied(std::size_t t_, std::size_t u_)
26                : t(t_), u(u_) {}
27
28            std::size_t t;
29            std::size_t u;
30        };
31
32        template< class CopyableRandomAccessRng >
33        inline CopyableRandomAccessRng
34        operator|( const CopyableRandomAccessRng& r, const copied& f )
35        {
36            iterator_range<
37                BOOST_DEDUCED_TYPENAME range_iterator<const
38                                               CopyableRandomAccessRng>::type >
39            temp( adaptors::slice( r, f.t, f.u ) );
40            return CopyableRandomAccessRng( temp.begin(), temp.end() );
41        }
42
43        template<class CopyableRandomAccessRange>
44        inline CopyableRandomAccessRange
45        copy(const CopyableRandomAccessRange& rng, std::size_t t, std::size_t u)
46        {
47            iterator_range<
48                BOOST_DEDUCED_TYPENAME range_iterator<const
49                    CopyableRandomAccessRange>::type> temp(
50                        adaptors::slice(rng, t, u));
51
52            return CopyableRandomAccessRange( temp.begin(), temp.end() );
53        }
54    } // 'adaptors'
55
56}
57
58#endif