SeqAn3 3.3.0-rc.1
The Modern C++ library for sequence analysis.
repeat_n.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, 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 <concepts>
16
19
20namespace seqan3::detail
21{
22
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{
91inline constexpr auto repeat_n = detail::repeat_n_fn{};
92
93} // namespace seqan3::views
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_view.hpp:576
constexpr ptrdiff_t count
Count the occurrences of a type in a pack.
Definition: type_pack/traits.hpp:164
constexpr detail::repeat_fn repeat
A view factory that repeats a given value infinitely.
Definition: repeat.hpp:342
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition: repeat_n.hpp:91
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
The SeqAn namespace for views.
Definition: char_strictly_to.hpp:22
Provides the seqan3::views::repeat.
The underlying type of seqan3::views::repeat_n.
Definition: repeat_n.hpp:29
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:37
Provides seqan3::views::take_exactly and seqan3::views::take_exactly_or_throw.