SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
utility/views/convert.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <concepts>
13#include <ranges>
14
16
17namespace seqan3::views
18{
65template <typename out_t>
66inline constexpr auto convert = std::views::transform(
67 [](auto && in) -> out_t
68 {
69 static_assert(std::convertible_to<decltype(in) &&, out_t> || explicitly_convertible_to<decltype(in) &&, out_t>,
70 "The reference type of the input to views::convert is not convertible to out_t.");
71
72 if constexpr (std::convertible_to<decltype(in) &&, out_t>)
73 return std::forward<decltype(in)>(in);
74 else
75 return static_cast<out_t>(std::forward<decltype(in)>(in));
76 });
77
78} // namespace seqan3::views
constexpr auto convert
A view that converts each element in the input range (implicitly or via static_cast).
Definition utility/views/convert.hpp:66
Checks whether from can be explicitly converted to to.
The SeqAn namespace for views.
Definition char_strictly_to.hpp:19
Provides concepts that do not have equivalents in C++20.
Hide me