SeqAn3  3.0.0
The Modern C++ library for sequence analysis.
convert.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2019, 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 
16 #include <seqan3/std/concepts>
17 #include <seqan3/std/ranges>
18 
19 namespace seqan3::view
20 {
21 
66 template <typename out_t>
67 auto const convert = std::view::transform([] (auto const & in) -> out_t
68 {
69  if constexpr (ImplicitlyConvertibleTo<std::remove_reference_t<decltype(in)>, out_t>)
70  return in;
71  else
72  return static_cast<out_t>(in);
73 });
74 
76 
77 } // namespace seqan3::view
auto const convert
A view that converts each element in the input range (implicitly or via static_cast).
Definition: convert.hpp:67
Resolves to std::ranges::ImplicitlyConvertibleTo<type1, type2>().
Provides concepts for core language types and relations that don&#39;t have concepts in C++20 (yet)...
The Concepts library.
Adaptations of concepts from the Ranges TS.
The SeqAn3 namespace for views.
constexpr auto transform
A range adaptor that takes a invocable and returns a view of the elements with the invocable applied...
Definition: ranges:911