Code:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
namespace shim
{
using namespace std;
template
<
typename FIterator1
, typename FIterator2
>
bool is_permutation
(
FIterator1 fOrigin1
, FIterator1 fTerminus1
, FIterator2 fOrigin2
, FIterator2 fTerminus2
)
{
return((distance(fOrigin1, fTerminus1) == distance(fOrigin2, fTerminus2)) ? (is_permutation(fOrigin1, fTerminus1, fOrigin2)) : (false));
}
template
<
typename FIterator1
, typename FIterator2
, typename FPredicate
>
bool is_permutation
(
FIterator1 fOrigin1
, FIterator1 fTerminus1
, FIterator2 fOrigin2
, FIterator2 fTerminus2
, FPredicate fPredicate
)
{
return((distance(fOrigin1, fTerminus1) == distance(fOrigin2, fTerminus2)) ? (is_permutation(fOrigin1, fTerminus1, fOrigin2, fPredicate)) : (false));
}
}
int main()
{
std::vector<int> s1{1,2,3,4,5};
std::vector<int> s2{3,5,4,1,2};
std::vector<int> s3{3,5,4,1};
std::vector<int> s4{3,5,4,1,6};
std::cout << std::boolalpha << shim::is_permutation(s1.begin(), s1.end(), s2.begin(), s2.end()) << '\n';
std::cout << std::boolalpha << shim::is_permutation(s1.begin(), s1.end(), s3.begin(), s3.end()) << '\n';
std::cout << std::boolalpha << shim::is_permutation(s1.begin(), s1.end(), s4.begin(), s4.end()) << '\n';
return(0);
}