Horizon
Loading...
Searching...
No Matches
3rd_party
range-v3
range
v3
view
take_last.hpp
Go to the documentation of this file.
1
2
// Range v3 library
3
//
4
// Copyright Barry Revzin 2019-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
14
#ifndef RANGES_V3_VIEW_TAKE_LAST_HPP
15
#define RANGES_V3_VIEW_TAKE_LAST_HPP
16
17
#include <
concepts/concepts.hpp
>
18
19
#include <
range/v3/range_fwd.hpp
>
20
21
#include <
range/v3/functional/bind_back.hpp
>
22
#include <
range/v3/range/concepts.hpp
>
23
#include <
range/v3/range/operations.hpp
>
24
#include <
range/v3/view/drop_exactly.hpp
>
25
26
#include <range/v3/detail/prologue.hpp>
27
28
namespace
ranges
29
{
32
33
namespace
views
34
{
35
struct
take_last_base_fn
36
{
37
template
(
typename
Rng)(
38
requires
viewable_range<Rng>
AND
sized_range<Rng>
)
39
auto
operator()(Rng && rng, range_difference_t<Rng> n)
const
40
{
41
auto
sz = ranges::distance(rng);
42
return
drop_exactly(
static_cast<
Rng &&
>
(rng), sz > n ? sz - n : 0);
43
}
44
};
45
46
struct
take_last_fn
:
take_last_base_fn
47
{
48
using
take_last_base_fn::operator();
49
50
template
(
typename
Int)(
51
requires
detail::integer_like_<Int>)
52
constexpr
auto
operator()(Int n)
const
53
{
54
return
make_view_closure(bind_back(
take_last_base_fn
{}, n));
55
}
56
};
57
59
RANGES_INLINE_VARIABLE(
take_last_fn
, take_last)
60
}
// namespace views
62
}
// namespace ranges
63
64
#include <range/v3/detail/epilogue.hpp>
65
66
#endif
bind_back.hpp
ranges::sized_range
The sized_range concept.
ranges::viewable_range
The viewable_range concept.
concepts.hpp
drop_exactly.hpp
operations.hpp
concepts.hpp
range_fwd.hpp
ranges::views::take_last_base_fn
Definition
take_last.hpp:36
ranges::views::take_last_fn
Definition
take_last.hpp:47
Generated by
1.9.8