SeqAn3  3.0.3
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 
20 namespace seqan3::views
21 {
83 template <auto index>
84 inline constexpr auto elements = std::views::transform([] (auto && in) -> decltype(auto)
85 {
86  using std::get;
87  using seqan3::get;
88 
89  using element_t = decltype(in);
90 
91  static_assert(tuple_like<element_t>,
92  "You may only pass ranges to views::element_t whose reference_t models tuple_like.");
93 
94  // we need to explicitly remove && around temporaries to return values as values (and not as rvalue references)
95  // we cannot simply cast to std::tuple_element_t (or set that as return value), because some tuples, like
96  // our alphabet_tuple_base alphabets do not return that type when get is called on them (they return a proxy)
97  using ret_type = remove_rvalue_reference_t<decltype(get<index>(std::forward<element_t>(in)))>;
98  return static_cast<ret_type>(get<index>(std::forward<element_t>(in)));
99 });
100 
102 
103 } // namespace seqan3::views
104 
105 #ifdef SEQAN3_DEPRECATED_310
106 namespace seqan3::views
107 {
108 
113 template <auto index>
114 SEQAN3_DEPRECATED_310 inline constexpr auto get = views::elements<index>;
115 
116 } // namespace seqan3::views
117 #endif // SEQAN3_DEPRECATED_310
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
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:69
constexpr auto get
A view calling get on each element in a range.
Definition: elements.hpp:114
constexpr auto elements
A view calling get on each element in a range.
Definition: elements.hpp:84
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
#define SEQAN3_DEPRECATED_310
Deprecation message for SeqAn 3.1.0 release.
Definition: platform.hpp:203
Adaptations of concepts from the Ranges TS.
Provides seqan3::tuple_like.
Provides various type traits on generic types.