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-2021, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2021, 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 
15 #include <seqan3/std/concepts>
16 
19 
20 namespace seqan3::detail
21 {
22 
28 struct repeat_n_fn
29 {
36  template <typename value_t>
37  constexpr auto operator()(value_t && value, size_t const count) const
38  {
39  static_assert(std::copy_constructible<value_t>, "The value passed to repeat_n must be copy constructible.");
40 
41  return views::repeat(std::forward<value_t>(value)) | detail::take_exactly(count);
42  }
43 };
44 
45 } // namespace seqan3::detail
46 
47 namespace seqan3::views
48 {
49 
95 constexpr inline auto repeat_n = detail::repeat_n_fn{};
97 
98 } // namespace seqan3::views
The Concepts library.
constexpr ptrdiff_t count
Count the occurrences of a type in a pack.
Definition: traits.hpp:169
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:95
The SeqAn namespace for views.
Definition: char_to.hpp:22
Provides seqan3::views::take_exactly and seqan3::views::take_exactly_or_throw.
Provides the seqan3::views::repeat.