SeqAn3  3.0.0
The Modern C++ library for sequence analysis.
get.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 
17 #include <seqan3/std/ranges>
18 
19 namespace seqan3::view
20 {
65 template <auto index>
66 inline auto const get = std::view::transform([] (auto && in) -> decltype(auto)
67 {
68  using std::get;
69  using seqan3::get;
70  static_assert(TupleLike<decltype(in)>,
71  "You may only pass ranges to view::get whose reference_t models the TupleLike.");
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::view
typename remove_rvalue_reference< t >::type remove_rvalue_reference_t
Return the input type with && removed, but lvalue references preserved (TransformationTrait shortcut)...
Definition: basic.hpp:58
constexpr auto const & get(configuration< configs_t... > const &config) noexcept
Definition: configuration.hpp:578
Provides seqan3::TupleLike.
Adaptations of concepts from the Ranges TS.
The SeqAn3 namespace for views.
auto const get
A view calling std::get on each element in a range.
Definition: get.hpp:66
Provides various type traits on generic types.
constexpr auto transform
A range adaptor that takes a invocable and returns a view of the elements with the invocable applied...
Definition: ranges:911
Whether a type behaves like a tuple.