SeqAn3  3.0.1
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 
27 struct repeat_n_fn
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
seqan3::views
The SeqAn namespace for views.
Definition: view_to_simd.hpp:672
repeat.hpp
Provides the views::repeat_view.
concepts
The Concepts library.
seqan3::views::take_exactly
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
copy_constructible
The concept std::copy_constructible is satisfied if T is an lvalue reference type,...
take_exactly.hpp
Provides seqan3::views::take_exactly and seqan3::views::take_exactly_or_throw.
seqan3::views::repeat
constexpr detail::repeat_fn repeat
A view factory that repeats a given value infinitely.
Definition: repeat.hpp:350
seqan3::views::repeat_n
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition: repeat_n.hpp:94
seqan3::pack_traits::count
constexpr ptrdiff_t count
Count the occurrences of a type in a pack.
Definition: traits.hpp:134