Horizon
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
20
25
26#include <range/v3/detail/prologue.hpp>
27
28namespace ranges
29{
32
33 namespace views
34 {
36 {
37 template(typename 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
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
60 } // namespace views
62} // namespace ranges
63
64#include <range/v3/detail/epilogue.hpp>
65
66#endif
The sized_range concept.
The viewable_range concept.
RANGES_INLINE_VARIABLE(detail::to_container_fn< detail::from_range< std::vector > >, to_vector) template< template< typename... > class ContT > auto to(RANGES_HIDDEN_DETAIL(detail
For initializing a container of the specified type with the elements of an Range.
Definition: conversion.hpp:399
defer< bind_back, Fn, Ts... > bind_back
Definition: meta.hpp:994
Definition: take_last.hpp:36
Definition: take_last.hpp:47