42 #include <range/v3/algorithm/copy.hpp> 74 template <std::ranges::InputRange urng_t>
75 class view_persist :
public ranges::view_interface<view_persist<urng_t>>
79 std::shared_ptr<urng_t> urange;
85 using reference = reference_t<urng_t>;
88 using const_reference = std::conditional_t<const_iterable_concept<urng_t>, reference,
void>;
90 using value_type = value_type_t<urng_t>;
92 using size_type = detail::transformation_trait_or_t<seqan3::size_type<urng_t>,
void>;
94 using difference_type = difference_type_t<urng_t>;
98 using const_iterator = std::conditional_t<const_iterable_concept<urng_t>, iterator,
void>;
104 view_persist() =
default;
105 constexpr view_persist(view_persist
const & rhs) =
default;
106 constexpr view_persist(view_persist && rhs) =
default;
107 constexpr view_persist &
operator=(view_persist
const & rhs) =
default;
108 constexpr view_persist &
operator=(view_persist && rhs) =
default;
109 ~view_persist() =
default;
114 view_persist(urng_t && _urange) :
115 urange{
new urng_t{std::move(_urange)}}
135 iterator
begin() noexcept
137 return seqan3::begin(*urange);
141 const_iterator
begin() const noexcept
142 requires const_iterable_concept<urng_t>
144 return seqan3::begin(*urange);
148 const_iterator
cbegin() const noexcept
149 requires const_iterable_concept<urng_t>
151 return seqan3::begin(*urange);
169 return seqan3::end(*urange);
173 auto end() const noexcept
174 requires const_iterable_concept<urng_t>
176 return seqan3::end(*urange);
180 auto cend() const noexcept
181 requires const_iterable_concept<urng_t>
183 return seqan3::end(*urange);
192 template <sequence_container_concept container_t>
193 operator container_t()
195 requires
std::CommonReference<
reference_t<container_t>, reference>
204 template <sequence_container_concept container_t>
205 operator container_t() const
207 requires
std::CommonReference<
reference_t<container_t>, reference> && const_iterable_concept<urng_t>
218 template <
typename urng_t>
219 view_persist(urng_t
const &) -> view_persist<std::remove_reference_t<urng_t>>;
227 class persist_fn :
public pipable_adaptor_base<persist_fn>
231 using base_t = pipable_adaptor_base<persist_fn>;
235 using base_t::base_t;
244 template <std::ranges::ViewableRange urng_t>
245 static auto impl(urng_t && urange)
247 return view::all(std::forward<urng_t>(urange));
253 template <std::ranges::Range urng_t>
254 static auto impl(urng_t && urange)
256 static_assert(!std::is_lvalue_reference_v<urng_t>,
"BUG: lvalue-reference in persist_fn::impl().");
257 return view_persist{std::move(urange)};
315 inline auto constexpr
persist = detail::persist_fn{};
::ranges::cbegin cbegin
Alias for ranges::cbegin. Returns an iterator to the beginning of a range.
Definition: ranges:245
Provides exceptions used in the I/O module.
Contains various shortcuts for common std::ranges functions.
SeqAn specific customisations in the standard namespace.
Definition: align_result.hpp:221
::ranges::copy copy
Alias for ranges::copy. Copies a range of elements to a new location.
Definition: ranges:200
t & operator=(t1 const &rhs)
Assignment operator.
Additional non-standard concepts for ranges.
Auxiliary header for the view submodule .
::ranges::iterator_t iterator_t
Alias for ranges::iterator_t. Obtains the iterator type of a range.
Definition: ranges:225
Adaptations of concepts from the Ranges TS.
::ranges::begin begin
Alias for ranges::begin. Returns an iterator to the beginning of a range.
Definition: ranges:185
Provides seqan3::view::all.
The SeqAn3 namespace for views.
auto constexpr persist
A view adaptor that wraps rvalue references of non-views.
Definition: persist.hpp:315
Definition: aligned_sequence_concept.hpp:288
constexpr auto all
A view that safely wraps a container (you will likely not need to use this unless defining a new view...
Definition: view_all.hpp:95
Provides various metafunctions used by the range module.
Provides various metafunctions for use on iterators.
::ranges::cend cend
Alias for ranges::cend. Returns an iterator to the end of a range.
Definition: ranges:250
Adaptations of concepts from the standard library.
constexpr auto back_inserter(container_t &container)
Create a std::back_insert_iterator for the argument.
Definition: iterator:79
::ranges::end end
Alias for ranges::end. Returns an iterator to the end of a range.
Definition: ranges:190