SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
repeat_n.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
4 // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5 // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6 // -----------------------------------------------------------------------------------------------------
7 
13 #pragma once
14 
17 #include <seqan3/std/concepts>
18 
19 namespace seqan3::detail
20 {
21 
28 {
35  template <typename value_t>
36  constexpr auto operator()(value_t && value, size_t const count) const
37  {
38  static_assert(std::copy_constructible<value_t>, "The value passed to repeat_n must be copy constructible.");
39 
40  return views::repeat(std::forward<value_t>(value)) | views::take_exactly(count);
41  }
42 };
43 
44 } // namespace seqan3::detail
45 
46 namespace seqan3::views
47 {
48 
94 constexpr inline auto repeat_n = detail::repeat_n_fn{};
96 
97 } // namespace seqan3::views
The Concepts library.
constexpr ptrdiff_t count
Count the occurrences of a type in a pack.
Definition: traits.hpp:168
constexpr detail::repeat_fn repeat
A view factory that repeats a given value infinitely.
Definition: repeat.hpp:355
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition: repeat_n.hpp:94
constexpr auto take_exactly
A view adaptor that returns the first size elements from the underlying range (or less if the underly...
Definition: take_exactly.hpp:77
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
The SeqAn namespace for views.
Definition: async_input_buffer.hpp:343
Provides the views::repeat_view.
The underlying type of seqan3::views::repeat_n.
Definition: repeat_n.hpp:28
constexpr auto operator()(value_t &&value, size_t const count) const
Creates a range of size count, where each element equals value.
Definition: repeat_n.hpp:36
Provides seqan3::views::take_exactly and seqan3::views::take_exactly_or_throw.