mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-29 11:16:29 +03:00
container: allow sort_and_unique to have a comparator
This commit is contained in:
committed by
Matthew Barr
parent
cea8f452f2
commit
dc50ab291b
@@ -90,9 +90,9 @@ auto make_vector_from(const std::pair<It, It> &range)
|
||||
}
|
||||
|
||||
/** \brief Sort a sequence container and remove duplicates. */
|
||||
template <typename C>
|
||||
void sort_and_unique(C &container) {
|
||||
std::sort(std::begin(container), std::end(container));
|
||||
template <typename C, typename Compare = std::less<typename C::value_type>>
|
||||
void sort_and_unique(C &container, Compare comp = Compare()) {
|
||||
std::sort(std::begin(container), std::end(container), comp);
|
||||
container.erase(std::unique(std::begin(container), std::end(container)),
|
||||
std::end(container));
|
||||
}
|
||||
|
Reference in New Issue
Block a user