SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
get.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 
15 #include <seqan3/std/ranges>
16 
19 
20 namespace seqan3::views
21 {
65 template <auto index>
66 inline auto const get = std::views::transform([] (auto && in) -> decltype(auto)
67 {
68  using std::get;
69  using seqan3::get;
70  static_assert(tuple_like<decltype(in)>,
71  "You may only pass ranges to views::get whose reference_t models the tuple_like.");
72 
73  // we need to explicitly remove && around temporaries to return values as values (and not as rvalue references)
74  // we cannot simply cast to std::tuple_element_t (or set that as return value), because some tuples, like
75  // our alphabet_tuple_base alphabets do not return that type when get is called on them (they return a proxy)
76  using ret_type = remove_rvalue_reference_t<decltype(get<index>(std::forward<decltype(in)>(in)))>;
77  return static_cast<ret_type>(get<index>(std::forward<decltype(in)>(in)));
78 });
79 
81 
82 } // namespace seqan3::views
T forward(T... args)
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:434
typename remove_rvalue_reference< t >::type remove_rvalue_reference_t
Return the input type with && removed, but lvalue references preserved (transformation_trait shortcut...
Definition: basic.hpp:68
auto const get
A view calling std::get on each element in a range.
Definition: get.hpp:66
Whether a type behaves like a tuple.
The SeqAn namespace for views.
Definition: async_input_buffer.hpp:343
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:434
Adaptations of concepts from the Ranges TS.
Provides seqan3::tuple_like.
Provides various type traits on generic types.