SeqAn3 3.1.0
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
20namespace seqan3::detail
21{
22
28struct 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
47namespace seqan3::views
48{
91constexpr inline auto repeat_n = detail::repeat_n_fn{};
92
93} // namespace seqan3::views
The <concepts> header from C++20's standard 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:347
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition: repeat_n.hpp:91
The SeqAn namespace for views.
Definition: char_to.hpp:22
Provides the seqan3::views::repeat.
Provides seqan3::views::take_exactly and seqan3::views::take_exactly_or_throw.