Skip to content

Commit

Permalink
remove type access from our tuple standin for device code and comment…
Browse files Browse the repository at this point in the history
… about what it's used for
  • Loading branch information
nmm0 committed Oct 2, 2024
1 parent 0fcdad7 commit 9f9a555
Showing 1 changed file with 3 additions and 32 deletions.
35 changes: 3 additions & 32 deletions include/experimental/__p0009_bits/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,6 @@ struct tuple_idx_matcher {
}
};

template<class SearchT, size_t Idx, class T>
struct tuple_type_matcher {
using type = tuple_member<T, Idx>;
template<class Other>
MDSPAN_FUNCTION
constexpr auto operator + (Other v) const {
if constexpr (std::is_same_v<T, SearchT>) { return *this; }
else { return v; }
}
};

template<class IdxSeq, class ... Elements>
struct tuple_impl;

Expand All @@ -134,19 +123,6 @@ struct tuple_impl<std::index_sequence<Idx...>, Elements...>: public tuple_member
MDSPAN_FUNCTION
constexpr tuple_impl(Elements ... vals):tuple_member<Elements, Idx>{vals}... {}

template<class T>
MDSPAN_FUNCTION
constexpr T& get() {
using base_t = decltype((tuple_type_matcher<T, Idx, Elements>() + ...) );
return base_t::type::get();
}
template<class T>
MDSPAN_FUNCTION
constexpr const T& get() const {
using base_t = decltype((tuple_type_matcher<T, Idx, Elements>() + ...) );
return base_t::type::get();
}

template<size_t N>
MDSPAN_FUNCTION
constexpr auto& get() {
Expand All @@ -161,20 +137,15 @@ struct tuple_impl<std::index_sequence<Idx...>, Elements...>: public tuple_member
}
};

// A simple tuple-like class for representing slices internally and is compatible with device code
// This doesn't support type access since we don't need it
// This is not meant as an external API
template<class ... Elements>
struct tuple: public tuple_impl<decltype(std::make_index_sequence<sizeof...(Elements)>()), Elements...> {
MDSPAN_FUNCTION
constexpr tuple(Elements ... vals):tuple_impl<decltype(std::make_index_sequence<sizeof...(Elements)>()), Elements ...>(vals ...) {}
};

template<class T, class ... Args>
MDSPAN_FUNCTION
constexpr auto& get(tuple<Args...>& vals) { return vals.template get<T>(); }

template<class T, class ... Args>
MDSPAN_FUNCTION
constexpr const T& get(const tuple<Args...>& vals) { return vals.template get<T>(); }

template<size_t Idx, class ... Args>
MDSPAN_FUNCTION
constexpr auto& get(tuple<Args...>& vals) { return vals.template get<Idx>(); }
Expand Down

0 comments on commit 9f9a555

Please sign in to comment.