Horizon
Loading...
Searching...
No Matches
indices.hpp
Go to the documentation of this file.
1
2// Range v3 library
3//
4// Copyright Eric Niebler 2013-present
5// Copyright Gonzalo Brito Gadeschi
6//
7// Use, modification and distribution is subject to the
8// Boost Software License, Version 1.0. (See accompanying
9// file LICENSE_1_0.txt or copy at
10// http://www.boost.org/LICENSE_1_0.txt)
11//
12// Project home: https://github.com/ericniebler/range-v3
13//
14
15#ifndef RANGES_V3_VIEW_INDICES_HPP
16#define RANGES_V3_VIEW_INDICES_HPP
17
18#include <meta/meta.hpp>
19
21
23#include <range/v3/utility/static_const.hpp>
25
26#include <range/v3/detail/prologue.hpp>
27
28namespace ranges
29{
30 namespace views
31 {
33 struct indices_fn : iota_view<std::size_t>
34 {
35 indices_fn() = default;
36
37 template(typename Val)(
38 requires integral<Val>)
39 iota_view<Val, Val> operator()(Val to) const
40 {
41 return {Val(), to};
42 }
43 template(typename Val)(
44 requires integral<Val>)
45 iota_view<Val, Val> operator()(Val from, Val to) const
46 {
47 return {from, to};
48 }
49 };
50
53 {
54 template(typename Val)(
55 requires integral<Val>)
56 closed_iota_view<Val> operator()(Val to) const
57 {
58 return {Val(), to};
59 }
60 template(typename Val)(
61 requires integral<Val>)
62 closed_iota_view<Val> operator()(Val from, Val to) const
63 {
64 return {from, to};
65 }
66 };
67
70 RANGES_INLINE_VARIABLE(indices_fn, indices)
71
72
74 RANGES_INLINE_VARIABLE(closed_indices_fn, closed_indices)
75 } // namespace views
76} // namespace ranges
77
78#include <range/v3/detail/epilogue.hpp>
79
80#endif // RANGES_V3_VIEW_INDICES_HPP
Tiny meta-programming library.
An iota view in a closed range.
Definition iota.hpp:184
Definition iota.hpp:333
Inclusive range of indices: [from, to].
Definition indices.hpp:53
Half-open range of indices: [from, to).
Definition indices.hpp:34