Loading...
Searching...
No Matches
utility/views/convert.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <concepts>
#include <ranges>
#include <seqan3/utility/concept.hpp>
namespace seqan3::views
{
template <typename out_t>
inline constexpr auto convert = std::views::transform(
[](auto && in) -> out_t
{
static_assert(std::convertible_to<decltype(in) &&, out_t> || explicitly_convertible_to<decltype(in) &&, out_t>,
"The reference type of the input to views::convert is not convertible to out_t.");
if constexpr (std::convertible_to<decltype(in) &&, out_t>)
return std::forward<decltype(in)>(in);
else
return static_cast<out_t>(std::forward<decltype(in)>(in));
});
} // namespace seqan3::views
std::forward
T forward(T... args)
seqan3::views::convert
constexpr auto convert
A view that converts each element in the input range (implicitly or via static_cast).
Definition utility/views/convert.hpp:66
explicitly_convertible_to
Checks whether from can be explicitly converted to to.
seqan3::views
The SeqAn namespace for views.
Definition char_strictly_to.hpp:19
concept.hpp
Provides concepts that do not have equivalents in C++20.
Hide me