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
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
15 \brief Range inline template implementation */
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
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)
30 return boost::make_iterator_range(
31 boost::make_transform_iterator(boost::begin(range), fn),
32 boost::make_transform_iterator(boost::end(range), fn) );
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)
41 return boost::make_iterator_range(
42 boost::make_transform_iterator(boost::begin(range), fn),
43 boost::make_transform_iterator(boost::end(range), fn) );
46 template <class Range, class Iterator>
47 prefix_ void senf::copy_range(Range const & range, Iterator const & i)
49 std::copy(boost::begin(range), boost::end(range), i);
52 template <class Range, class Iterator>
53 prefix_ void senf::copy_range(Range & range, Iterator const & i)
55 std::copy(boost::begin(range), boost::end(range), i);
58 template <class Range>
59 prefix_ bool senf::has_one_elt(Range r)
61 return ! r.empty() && boost::next(r.begin()) == r.end();
64 //-/////////////////////////////////////////////////////////////////////////////////////////////////
72 // c-file-style: "senf"
73 // indent-tabs-mode: nil
74 // ispell-local-dictionary: "american"
75 // compile-command: "scons -u test"