Horizon
indices.hpp
Go to the documentation of this file.
1 // 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 
20 #include <range/v3/range_fwd.hpp>
21 
23 #include <range/v3/utility/static_const.hpp>
24 #include <range/v3/view/iota.hpp>
25 
26 #include <range/v3/detail/prologue.hpp>
27 
28 namespace 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 
71 
72 
75  } // namespace views
76 } // namespace ranges
77 
78 #include <range/v3/detail/epilogue.hpp>
79 
80 #endif // RANGES_V3_VIEW_INDICES_HPP
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
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