CExA-project / ddc

DDC is a discrete domain computation library.
https://ddc.mdls.fr
Other
33 stars 5 forks source link

Add a `type_seq_length_v` property #592

Closed EmilyBourne closed 3 months ago

EmilyBourne commented 3 months ago

When working with type sequences to deduce new types it is useful to be able to check the number of arguments to the type seq. I would suggest calling this accessor type_seq_rank_v to match the rank property used elsewhere, eg: https://github.com/CExA-project/ddc/blob/362bb29f3dba481351340700d1fad225c5d6bf07/include/ddc/discrete_domain.hpp#L66-L69

However it seems that this accessor already exists and does something else: https://github.com/CExA-project/ddc/blob/362bb29f3dba481351340700d1fad225c5d6bf07/include/ddc/detail/type_seq.hpp#L185-L187

type_seq_length_v could be implemented simply as:

template <class TypeSeq>
constexpr std::size_t type_seq_length_v = std::numeric_limits<std::size_t>::max();

template <class... Tags>
constexpr std::size_t type_seq_length_v<ddc::detail::TypeSeq<Tags...>> = sizeof...(Tags);
tpadioleau commented 3 months ago

Seems fairly reasonable