Skip to content

Commit

Permalink
step 2
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Apr 26, 2021
1 parent 21605e1 commit 12956e4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 62 deletions.
28 changes: 23 additions & 5 deletions include/seqan3/alphabet/composite/alphabet_tuple_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,16 +348,16 @@ class alphabet_tuple_base :
* \stableapi{Since version 3.1.}
*/
template <size_t index>
friend constexpr auto get(alphabet_tuple_base & l) noexcept
constexpr auto get() noexcept
{
static_assert(index < sizeof...(component_types), "Index out of range.");

using t = meta::at_c<component_list, index>;
t val{};

seqan3::assign_rank_to(l.to_component_rank<index>(), val);
seqan3::assign_rank_to(to_component_rank<index>(), val);

return component_proxy<t, index>{val, l};
return component_proxy<t, index>{val, *this};
}

/*!\copybrief get
Expand All @@ -382,13 +382,13 @@ class alphabet_tuple_base :
* \stableapi{Since version 3.1.}
*/
template <size_t index>
friend constexpr auto get(alphabet_tuple_base const & l) noexcept
constexpr auto get() const noexcept
{
static_assert(index < sizeof...(component_types), "Index out of range.");

using t = meta::at_c<component_list, index>;

return seqan3::assign_rank_to(l.to_component_rank<index>(), t{});
return seqan3::assign_rank_to(to_component_rank<index>(), t{});
}

/*!\copybrief get
Expand Down Expand Up @@ -762,11 +762,29 @@ class alphabet_tuple_base<derived_type, component_types...>::component_proxy : p
//!\}
};

//!\brief The same as [std::get](https://en.cppreference.com/w/cpp/utility/tuple/get) on an std::tuple.
//!\relates seqan3::alphabet_tuple_base
template <size_t index, typename ...types>
constexpr auto get(alphabet_tuple_base<types...> & l) noexcept
{
return l.template get<index>();
}

//!\brief The same as [std::get](https://en.cppreference.com/w/cpp/utility/tuple/get) on an std::tuple.
//!\relates seqan3::alphabet_tuple_base
template <size_t index, typename ...types>
constexpr auto get(alphabet_tuple_base<types...> const & l) noexcept
{
return l.template get<index>();
}

} // namespace seqan3

namespace std
{

using seqan3::get;

/*!\brief Obtains the type of the specified element.
* \implements seqan3::transformation_trait
* \ingroup composite
Expand Down
7 changes: 7 additions & 0 deletions include/seqan3/alphabet/quality/qualified.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,10 @@ qualified(sequence_alphabet_type &&, quality_alphabet_type &&)
-> qualified<std::decay_t<sequence_alphabet_type>, std::decay_t<quality_alphabet_type>>;

} // namespace seqan3

namespace std
{

using seqan3::get;

} // namespace std
21 changes: 21 additions & 0 deletions include/seqan3/std/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,27 @@ using ::ranges::cpp20::views::keys;
using ::ranges::cpp20::views::values;
} // namespace views

// [range.elements]
namespace views
{

namespace
{

template <size_t index>
inline constexpr auto elements = std::ranges::views::transform([] (auto && in) -> decltype(auto)
{
using get_return_t = decltype(std::get<index>(std::forward<decltype(in)>(in)));
using return_t = std::conditional_t<std::is_rvalue_reference_v<get_return_t>,
std::remove_reference_t<get_return_t>,
get_return_t>;
return static_cast<return_t>(std::get<index>(std::forward<decltype(in)>(in)));
});

} // anonymous namespace

} // namespace views

} // anonymous namespace

} // namespace std::ranges
Expand Down
58 changes: 1 addition & 57 deletions include/seqan3/utility/tuple/pod_tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,63 +288,7 @@ constexpr auto const && get(seqan3::pod_tuple<arg_types...> const && t) noexcept
namespace std
{

//!\cond
template <std::size_t i, typename ...types>
constexpr auto & get(seqan3::pod_tuple<types...> & t) noexcept
requires (i < sizeof...(types))
{
return seqan3::get<i>(t);
}

template <std::size_t i, typename ...types>
constexpr auto const & get(seqan3::pod_tuple<types...> const & t) noexcept
requires (i < sizeof...(types))
{
return seqan3::get<i>(t);
}

template <std::size_t i, typename ...types>
constexpr auto && get(seqan3::pod_tuple<types...> && t) noexcept
requires (i < sizeof...(types))
{
return seqan3::get<i>(std::move(t));
}

template <std::size_t i, typename ...types>
constexpr auto const && get(seqan3::pod_tuple<types...> const && t) noexcept
requires (i < sizeof...(types))
{
return seqan3::get<i>(std::move(t));
}

template <typename type, typename ...types>
constexpr auto & get(seqan3::pod_tuple<types...> & t) noexcept
requires (seqan3::pack_traits::count<type, types...> == 1)
{
return seqan3::get<type>(t);
}

template <typename type, typename ...types>
constexpr auto const & get(seqan3::pod_tuple<types...> const & t) noexcept
requires (seqan3::pack_traits::count<type, types...> == 1)
{
return seqan3::get<type>(t);
}

template <typename type, typename ...types>
constexpr auto && get(seqan3::pod_tuple<types...> && t) noexcept
requires (seqan3::pack_traits::count<type, types...> == 1)
{
return seqan3::get<type>(std::move(t));
}

template <typename type, typename ...types>
constexpr auto const && get(seqan3::pod_tuple<types...> const && t) noexcept
requires (seqan3::pack_traits::count<type, types...> == 1)
{
return seqan3::get<type>(std::move(t));
}
//!\endcond
using seqan3::get;

/*!\brief Obtains the type of the specified element.
* \implements seqan3::transformation_trait
Expand Down

0 comments on commit 12956e4

Please sign in to comment.