Horizon
Loading...
Searching...
No Matches
sort_n_with_buffer.hpp
Go to the documentation of this file.
1
2// Range v3 library
3//
4// Copyright Eric Niebler 2014-present
5//
6// Use, modification and distribution is subject to the
7// Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10//
11// Project home: https://github.com/ericniebler/range-v3
12//
13// Copyright (c) 2009 Alexander Stepanov and Paul McJones
14//
15// Permission to use, copy, modify, distribute and sell this software
16// and its documentation for any purpose is hereby granted without
17// fee, provided that the above copyright notice appear in all copies
18// and that both that copyright notice and this permission notice
19// appear in supporting documentation. The authors make no
20// representations about the suitability of this software for any
21// purpose. It is provided "as is" without express or implied
22// warranty.
23//
24// Algorithms from
25// Elements of Programming
26// by Alexander Stepanov and Paul McJones
27// Addison-Wesley Professional, 2009
28#ifndef RANGES_V3_ALGORITHM_AUX_SORT_N_WITH_BUFFER_HPP
29#define RANGES_V3_ALGORITHM_AUX_SORT_N_WITH_BUFFER_HPP
30
31#include <tuple>
32
34
41#include <range/v3/utility/static_const.hpp>
42
43#include <range/v3/detail/prologue.hpp>
44
45namespace ranges
46{
47 namespace aux
48 {
50 {
51 template(typename I, typename B, typename C = less, typename P = identity)(
52 requires same_as<iter_common_reference_t<I>,
53 iter_common_reference_t<B>> AND
54 indirectly_copyable<I, B> AND mergeable<B, I, I, C, P, P>)
55 I operator()(I first, iter_difference_t<I> n, B buff, C r = C{}, P p = P{})
56 const
57 {
58 auto half = n / 2;
59 if(0 == half)
60 return next(first, n);
61 I m = (*this)(first, half, buff, r, p);
62 (*this)(m, n - half, buff, r, p);
63 return merge_n_with_buffer(first, half, m, n - half, buff, r, p);
64 }
65 };
66
67 RANGES_INLINE_VARIABLE(sort_n_with_buffer_fn, sort_n_with_buffer)
68 } // namespace aux
69} // namespace ranges
70
71#include <range/v3/detail/epilogue.hpp>
72
73#endif
The indirectly_copyable concept.
Definition sort_n_with_buffer.hpp:50
Definition identity.hpp:25
Definition comparisons.hpp:50