ericniebler/meta

Does __make_integer_seq intrinsic make it possible to implement meta::take in O(1)?

ericniebler opened this issue · 3 comments

Does __make_integer_seq intrinsic make it possible to implement meta::take in O(1)?
gabyx commented

what does meta::take do? is it already implemented?

(take the n-th element?)

See take from the Haskell Prelude for a description. Meta already has drop, but I haven't found a way to implement take in O(1) so I haven't provided it.

You can prepare the pack of indices you want to take in O(1) (using __make_integer_seq, and then expand into a list using the __type_pack_element intrinsic explained in a blog post). That's technically O(K) for K elements taken because you have multiple calls to __type_pack_element, but may still be fast since it's an intrinsic. I've also worked on another intrinsic to basically take a subsequence of a parameter pack, but never submitted it for review in Clang.