Horizon
iota.hpp
Go to the documentation of this file.
1 // Range v3 library
3 //
4 // Copyright Eric Niebler 2013-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 #ifndef RANGES_V3_NUMERIC_IOTA_HPP
14 #define RANGES_V3_NUMERIC_IOTA_HPP
15 
21 #include <range/v3/utility/static_const.hpp>
22 
23 #include <range/v3/detail/prologue.hpp>
24 
25 namespace ranges
26 {
29  struct iota_fn
30  {
31  template(typename O, typename S, typename T)(
32  requires output_iterator<O, T const &> AND sentinel_for<S, O> AND
33  weakly_incrementable<T>)
34  O operator()(O first, S last, T val) const
35  {
36  for(; first != last; ++first, ++val)
37  *first = detail::as_const(val);
38  return first;
39  }
40 
41  template(typename Rng, typename T)(
42  requires output_range<Rng, T const &> AND weakly_incrementable<T>)
43  borrowed_iterator_t<Rng> operator()(Rng && rng, T val) const //
44  {
45  return (*this)(begin(rng), end(rng), detail::move(val));
46  }
47  };
48 
51 } // namespace ranges
52 
53 #include <range/v3/detail/epilogue.hpp>
54 
55 #endif
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
front< Pair > first
Retrieve the first element of the pair Pair.
Definition: meta.hpp:2251
Definition: iota.hpp:30