SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
convert.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, 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::views
20 {
21 
70 template <typename out_t>
71 auto const convert = std::views::transform([] (auto && in) -> out_t
72 {
73  static_assert(std::convertible_to<decltype(in) &&, out_t> || explicitly_convertible_to<decltype(in) &&, out_t>,
74  "The reference type of the input to views::convert is not convertible to out_t.");
75 
76  if constexpr (std::convertible_to<decltype(in) &&, out_t>)
77  return std::forward<decltype(in)>(in);
78  else
79  return static_cast<out_t>(std::forward<decltype(in)>(in));
80 });
81 
83 
84 } // namespace seqan3::views
seqan3::views
The SeqAn namespace for views.
Definition: view_iota_simd.hpp:218
explicitly_convertible_to
Resolves to std::ranges::explicitly_convertible_to<type1, type2>().
concepts
The Concepts library.
core_language.hpp
Provides concepts for core language types and relations that don't have concepts in C++20 (yet).
ranges
Adaptations of concepts from the Ranges TS.
seqan3::pack_traits::transform
seqan3::type_list< trait_t< pack_t >... > transform
Apply a transformation trait to every type in the pack and return a seqan3::type_list of the results.
Definition: traits.hpp:307
seqan3::views::convert
auto const convert
A view that converts each element in the input range (implicitly or via static_cast).
Definition: convert.hpp:71