SeqAn3  3.0.1
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 
17 #include <seqan3/std/ranges>
18 
19 namespace seqan3::views
20 {
64 template <auto index>
65 inline auto const get = std::views::transform([] (auto && in) -> decltype(auto)
66 {
67  using std::get;
68  using seqan3::get;
69  static_assert(tuple_like<decltype(in)>,
70  "You may only pass ranges to views::get whose reference_t models the tuple_like.");
71 
72  // we need to explicitly remove && around temporaries to return values as values (and not as rvalue references)
73  // we cannot simply cast to std::tuple_element_t (or set that as return value), because some tuples, like
74  // our alphabet_tuple_base alphabets do not return that type when get is called on them (they return a proxy)
75  using ret_type = remove_rvalue_reference_t<decltype(get<index>(std::forward<decltype(in)>(in)))>;
76  return static_cast<ret_type>(get<index>(std::forward<decltype(in)>(in)));
77 });
78 
80 
81 } // namespace seqan3::views
seqan3::views
The SeqAn namespace for views.
Definition: view_to_simd.hpp:672
tuple.hpp
Provides seqan3::tuple_like.
basic.hpp
Provides various type traits on generic types.
seqan3::views::get
const auto get
A view calling std::get on each element in a range.
Definition: get.hpp:65
std::forward
T forward(T... args)
seqan3::remove_rvalue_reference_t
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:58
tuple_like
Whether a type behaves like a tuple.
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::get
constexpr const auto & 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:576