Range.cti
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief Range inline template implementation */
16 
17 //#include "Range.ih"
18 
19 // Custom includes
20 
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 template <class Range, class Fn>
25 prefix_ boost::iterator_range<
26  boost::transform_iterator< Fn,
27  typename boost::range_const_iterator<Range>::type > >
28 senf::make_transform_range(Range const & range, Fn const & fn)
29 {
30  return boost::make_iterator_range(
31  boost::make_transform_iterator(boost::begin(range), fn),
32  boost::make_transform_iterator(boost::end(range), fn) );
33 }
34 
35 template <class Range, class Fn>
36 prefix_ boost::iterator_range<
37  boost::transform_iterator< Fn,
38  typename boost::range_iterator<Range>::type > >
39 senf::make_transform_range(Range & range, Fn const & fn)
40 {
41  return boost::make_iterator_range(
42  boost::make_transform_iterator(boost::begin(range), fn),
43  boost::make_transform_iterator(boost::end(range), fn) );
44 }
45 
46 template <class Range, class Iterator>
47 prefix_ void senf::copy_range(Range const & range, Iterator const & i)
48 {
49  std::copy(boost::begin(range), boost::end(range), i);
50 }
51 
52 template <class Range, class Iterator>
53 prefix_ void senf::copy_range(Range & range, Iterator const & i)
54 {
55  std::copy(boost::begin(range), boost::end(range), i);
56 }
57 
58 template <class Range>
59 prefix_ bool senf::has_one_elt(Range r)
60 {
61  return ! r.empty() && boost::next(r.begin()) == r.end();
62 }
63 
64 //-/////////////////////////////////////////////////////////////////////////////////////////////////
65 #undef prefix_
66 
67 
68 // Local Variables:
69 // mode: c++
70 // fill-column: 100
71 // comment-column: 40
72 // c-file-style: "senf"
73 // indent-tabs-mode: nil
74 // ispell-local-dictionary: "american"
75 // compile-command: "scons -u test"
76 // End: