Skip to content

Deduplicating types in a list #151

Answered by brunocodutra
spayne-pgh asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @spayne-pgh, glad to hear you're considering Metal. An implementation of unique is not currently available out of the box, but can be easily implemented out of the primitives Metal offers, in fact it's a short one-liner:

template<class seq>
using unique = accumulate<bind<lambda<if_>, lambda<contains>, _1, lambda<append>>, list<>, seq>;

You can try it live on compiler explorer, is that what you were looking for?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@spayne-pgh
Comment options

Answer selected by spayne-pgh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants