SeqAn3 3.2.0
The Modern C++ library for sequence analysis.
elements.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, 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 <ranges>
16
19
20namespace seqan3::views
21{
79template <auto index>
80inline constexpr auto elements = std::views::transform(
81 [](auto && in) -> decltype(auto)
82 {
83 using std::get;
84 using seqan3::get;
85
86 using element_t = decltype(in);
87
88 static_assert(tuple_like<element_t>,
89 "You may only pass ranges to views::element_t whose reference_t models tuple_like.");
90
91 // we need to explicitly remove && around temporaries to return values as values (and not as rvalue references)
92 // we cannot simply cast to std::tuple_element_t (or set that as return value), because some tuples, like
93 // our alphabet_tuple_base alphabets do not return that type when get is called on them (they return a proxy)
94 using ret_type = remove_rvalue_reference_t<decltype(get<index>(std::forward<element_t>(in)))>;
95 return static_cast<ret_type>(get<index>(std::forward<element_t>(in)));
96 });
97
98} // 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:470
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_strictly_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:415
Provides seqan3::tuple_like.