Last active
April 9, 2017 12:48
-
-
Save deque-blog/c1ce60d2a4a2c7a4ce96a1038dad0316 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template < | |
typename LhsForwardIterator, | |
typename RhsForwardIterator, | |
typename Less = std::less<typename LhsForwardIterator::value_type> | |
> | |
bool is_permutation_less( | |
LhsForwardIterator lhs_first, LhsForwardIterator lhs_last, | |
RhsForwardIterator rhs_first, RhsForwardIterator rhs_last, | |
Less less = Less()) | |
{ | |
using value_type = typename LhsForwardIterator::value_type; | |
std::vector<value_type> lhs(lhs_first, lhs_last); | |
std::vector<value_type> rhs(rhs_first, rhs_last); | |
if (lhs.size() != rhs.size()) | |
return false; | |
std::sort(begin(lhs), end(lhs)); | |
std::sort(begin(rhs), end(rhs)); | |
return lhs == rhs; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment