SeqAn3 3.1.0
The Modern C++ library for sequence analysis.
elements.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2021, 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
15#include <seqan3/std/ranges>
16
19
20namespace seqan3::views
21{
79template <auto index>
80inline constexpr auto elements = std::views::transform([] (auto && in) -> decltype(auto)
81{
82 using std::get;
83 using seqan3::get;
84
85 using element_t = decltype(in);
86
87 static_assert(tuple_like<element_t>,
88 "You may only pass ranges to views::element_t whose reference_t models tuple_like.");
89
90 // we need to explicitly remove && around temporaries to return values as values (and not as rvalue references)
91 // we cannot simply cast to std::tuple_element_t (or set that as return value), because some tuples, like
92 // our alphabet_tuple_base alphabets do not return that type when get is called on them (they return a proxy)
93 using ret_type = remove_rvalue_reference_t<decltype(get<index>(std::forward<element_t>(in)))>;
94 return static_cast<ret_type>(get<index>(std::forward<element_t>(in)));
95});
96
97} // namespace seqan3::views
Provides various type traits on generic types.
decltype(detail::transform< trait_t >(list_t{})) transform
Apply a transformation trait to every type in the list and return a seqan3::type_list of the results.
Definition: traits.hpp:471
constexpr auto elements
A view calling get on each element in a range.
Definition: elements.hpp:80
Whether a type behaves like a tuple.
The SeqAn namespace for views.
Definition: char_to.hpp:22
constexpr auto const & get(configuration< configs_t... > const &config) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: configuration.hpp:429
The <ranges> header from C++20's standard library.
Provides seqan3::tuple_like.