Talk:cpp/algorithm/is permutation
From cppreference.com
Added requirement that predicate be an equivalence relation. An example code for this is:
#include <algorithm> #include <iostream> #include <vector> int main() { const auto p = [] (const auto lhs, const auto rhs) { return std::abs(lhs - rhs) < 2; }; const std::vector<int> v0{1, 0}, v1{1, 2}, v0prime{0, 1}; std::cout << "v0 is permutation of v1 w.r.t. predicate p: " << std::is_permutation(v0.cbegin(), v0.cend(), v1.cbegin(), v1.cend(), p) << '\n'; std::cout << "v0prime is permutation of v1 w.r.t. predicate p: " << std::is_permutation(v0prime.cbegin(), v0prime.cend(), v1.cbegin(), v1.cend(), p) << '\n'; return 0; }
80.147.162.235 22:39, 6 April 2017 (PDT)